/** * <p>Write the tag contained in this AudioFile in the actual file on the disk, this is the same as calling the <code>AudioFileIO.write(this)</code> method. * * @throws NoWritePermissionsException if the file could not be written to due to file permissions * @throws CannotWriteException If the file could not be written/accessed, the extension wasn't recognized, or other IO error occured. * @see AudioFileIO */ public void commit() throws CannotWriteException { AudioFileIO.write(this); }
/** * This method returns the default instance for static use.<br> * * @return The default instance. */ public static AudioFileIO getDefaultAudioFileIO() { if (defaultInstance == null) { defaultInstance = new AudioFileIO(); } return defaultInstance; }
/** * <p/> * Delete the tag, if any, contained in the given file. * </p> * * @param f The file where the tag will be deleted * @throws CannotWriteException If the file could not be written/accessed, the extension * wasn't recognized, or other IO error occurred. * @throws org.jaudiotagger.audio.exceptions.CannotReadException */ public static void delete(AudioFile f) throws CannotReadException, CannotWriteException { getDefaultAudioFileIO().deleteTag(f); }
/** * <p/> * Write the tag contained in the audioFile in the actual file on the disk. * </p> * * @param f The AudioFile to be written * @throws CannotWriteException If the file could not be written/accessed, the extension * wasn't recognized, or other IO error occurred. */ public static void write(AudioFile f) throws CannotWriteException { getDefaultAudioFileIO().writeFile(f); }
/** * * Read the tag contained in the given file. * * * @param f The file to read. * @return The AudioFile with the file tag and the file encoding info. * @throws org.jaudiotagger.audio.exceptions.CannotReadException If the file could not be read, the extension wasn't * recognized, or an IO error occurred during the read. * @throws org.jaudiotagger.tag.TagException * @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException * @throws java.io.IOException * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException */ public static AudioFile read(File f) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException { return getDefaultAudioFileIO().readFile(f); }
/** * Recursive function to scan directory * * @param dir */ private void scanSingleDir(final File dir) { final File[] audioFiles = dir.listFiles(new AudioFileFilter(false)); if (audioFiles.length > 0) { for (File audioFile : audioFiles) { count++; try { AudioFileIO.read(audioFile); } catch (Throwable t) { System.err.println("Unable to read record:" + count + ":" + audioFile.getPath()); failed++; t.printStackTrace(); } } } final File[] audioFileDirs = dir.listFiles(new DirFilter()); if (audioFileDirs.length > 0) { for (File audioFileDir : audioFileDirs) { scanSingleDir(audioFileDir); } } }
@Override public void write(Track track) throws TagWriteException { try { org.jaudiotagger.audio.AudioFile af1 = AudioFileIO.read(track.getTrackData().getFile()); Tag abstractTag = af1.getTagOrCreateDefault(); copyTagFields(abstractTag, new VorbisCommentTag(), track); AudioFileIO.write(af1); } catch (Exception e) { throw new TagWriteException(e); } }
/** * <p/> * Read the tag contained in the given file. * </p> * * @param f The file to read. * @return The AudioFile with the file tag and the file encoding info. * @throws CannotReadException If the file could not be read, the extension wasn't * recognized, or an IO error occurred during the read. * @throws org.jaudiotagger.tag.TagException * @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException * @throws java.io.IOException * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException */ public AudioFile readFile(File f) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException { checkFileExists(f); String ext = Utils.getExtension(f); AudioFileReader afr = readers.get(ext); if (afr == null) { throw new CannotReadException(ErrorMessage.NO_READER_FOR_THIS_FORMAT.getMsg(ext)); } return afr.read(f); }
/** * * Read the tag contained in the given file. * * * @param f The file to read. * @return The AudioFile with the file tag and the file encoding info. * @throws org.jaudiotagger.audio.exceptions.CannotReadException If the file could not be read, the extension wasn't * recognized, or an IO error occurred during the read. * @throws org.jaudiotagger.tag.TagException * @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException * @throws java.io.IOException * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException */ public static AudioFile readMagic(File f) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException { return getDefaultAudioFileIO().readFileMagic(f); }
/** * * Read the tag contained in the given file. * * * @param f The file to read. * @param ext The extension to be used. * @return The AudioFile with the file tag and the file encoding info. * @throws org.jaudiotagger.audio.exceptions.CannotReadException If the file could not be read, the extension wasn't * recognized, or an IO error occurred during the read. * @throws org.jaudiotagger.tag.TagException * @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException * @throws java.io.IOException * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException */ public static AudioFile readAs(File f,String ext) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException { return getDefaultAudioFileIO().readFileAs(f,ext); }
/** * Creates an instance. */ public AudioFileIO() { this.modificationHandler = new ModificationHandler(); prepareReadersAndWriters(); }
public void setFile(File file) throws InvalidAttributesException, CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException{ if(!file.exists()) { throw new InvalidAttributesException("Song file doesnt exist:"+file.getAbsolutePath()); } this.file=file; if(setTag(AudioFileIO.read(file).getTag())) { reloadAttributesFromFile(); } } protected boolean setTag(Tag t) {
@Override public void write(Track track) throws TagWriteException { try { org.jaudiotagger.audio.AudioFile af1 = AudioFileIO.read(track.getTrackData().getFile()); Tag abstractTag = af1.getTag(); copyTagFields(abstractTag, new Mp4Tag(), track); // workaround since track/tracktotal and disc/disctotal share same field handleTrackDiscFields(abstractTag, track); // workaround since genre and genre custom field types used handleGenreFields(abstractTag, track); AudioFileIO.write(af1); } catch (Exception e) { throw new TagWriteException(e); } }
/** * <p/> * Write the tag contained in the audioFile in the actual file on the disk. * </p> * * @param f The AudioFile to be written * @throws CannotWriteException If the file could not be written/accessed, the extension * wasn't recognized, or other IO error occurred. */ public static void write(AudioFile f) throws CannotWriteException { getDefaultAudioFileIO().writeFile(f); }
/** * <p/> * Read the tag contained in the given file. * </p> * * @param f The file to read. * @return The AudioFile with the file tag and the file encoding info. * @throws CannotReadException If the file could not be read, the extension wasn't * recognized, or an IO error occurred during the read. * @throws org.jaudiotagger.tag.TagException * @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException * @throws java.io.IOException * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException */ public static AudioFile read(File f) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException { return getDefaultAudioFileIO().readFile(f); }
/** * <p/> * Read the tag contained in the given file. * </p> * * @param f The file to read. * @return The AudioFile with the file tag and the file encoding info. * @throws CannotReadException If the file could not be read, the extension wasn't * recognized, or an IO error occurred during the read. * @throws org.jaudiotagger.tag.TagException * * @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException * * @throws java.io.IOException * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException * */ public AudioFile readFile(File f) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException { checkFileExists(f); String ext = Utils.getExtension(f); AudioFileReader afr = readers.get(ext); if (afr == null) { throw new CannotReadException(ErrorMessage.NO_READER_FOR_THIS_FORMAT.getMsg(ext)); } return afr.read(f); }
/** * Creates an instance. */ public AudioFileIO() { this.modificationHandler = new ModificationHandler(); prepareReadersAndWriters(); }
try AudioFileIO.read(audioFile);
/** * * Write the tag contained in the audioFile in the actual file on the disk. * * * @param f The AudioFile to be written * @throws NoWritePermissionsException if the file could not be written to due to file permissions * @throws CannotWriteException If the file could not be written/accessed, the extension * wasn't recognized, or other IO error occurred. */ public static void write(AudioFile f) throws CannotWriteException { getDefaultAudioFileIO().writeFile(f,null); }