|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jaudiotagger.audio.AudioFileIO
public class AudioFileIO
The main entry point for the Tag Reading/Writing operations, this class will select the appropriate reader/writer for the given file. It selects the appropriate reader/writer based on the file extension (case ignored). Here is an simple example of use:
AudioFile audioFile = AudioFileIO.read(new File("audiofile.mp3")); //Reads the given file.
int bitrate = audioFile.getBitrate(); //Retreives the bitrate of the file.
String artist = audioFile.getTag().getFirst(TagFieldKey.ARTIST); //Retreive the artist name.
audioFile.getTag().setGenre("Progressive Rock"); //Sets the genre to Prog. Rock, note the file on disk is still unmodified.
AudioFileIO.write(audioFile); //Write the modifications in the file on disk.
You can also use the commit() method defined for
AudioFiles to achieve the same goal as
AudioFileIO.write(File), like this:
AudioFile audioFile = AudioFileIO.read(new File("audiofile.mp3"));
audioFile.getTag().setGenre("Progressive Rock");
audioFile.commit(); //Write the modifications in the file on disk.
AudioFile,
Tag| Field Summary | |
|---|---|
private static AudioFileIO |
defaultInstance
This field contains the default instance for static use. |
static java.util.logging.Logger |
logger
|
private ModificationHandler |
modificationHandler
This member is used to broadcast modification events to registered |
private java.util.Map<java.lang.String,AudioFileReader> |
readers
|
private java.util.Map<java.lang.String,AudioFileWriter> |
writers
|
| Constructor Summary | |
|---|---|
AudioFileIO()
Creates an instance. |
|
| Method Summary | |
|---|---|
void |
addAudioFileModificationListener(AudioFileModificationListener listener)
Adds an listener for all file formats. |
void |
checkFileExists(java.io.File file)
Check does file exist |
static void |
delete(AudioFile f)
Delete the tag, if any, contained in the given file. |
void |
deleteTag(AudioFile f)
Delete the tag, if any, contained in the given file. |
static AudioFileIO |
getDefaultAudioFileIO()
This method returns the default instance for static use. |
private void |
prepareReadersAndWriters()
Creates the readers and writers. |
static AudioFile |
read(java.io.File f)
Read the tag contained in the given file. |
AudioFile |
readFile(java.io.File f)
Read the tag contained in the given file. |
void |
removeAudioFileModificationListener(AudioFileModificationListener listener)
Removes an listener for all file formats. |
static void |
write(AudioFile f)
Write the tag contained in the audioFile in the actual file on the disk. |
void |
writeFile(AudioFile f)
Write the tag contained in the audioFile in the actual file on the disk. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static java.util.logging.Logger logger
private static AudioFileIO defaultInstance
private final ModificationHandler modificationHandler
private java.util.Map<java.lang.String,AudioFileReader> readers
private java.util.Map<java.lang.String,AudioFileWriter> writers
| Constructor Detail |
|---|
public AudioFileIO()
| Method Detail |
|---|
public static void delete(AudioFile f)
throws CannotReadException,
CannotWriteException
f - The file where the tag will be deleted
CannotWriteException - If the file could not be written/accessed, the extension
wasn't recognized, or other IO error occurred.
CannotReadExceptionpublic static AudioFileIO getDefaultAudioFileIO()
public static AudioFile read(java.io.File f)
throws CannotReadException,
java.io.IOException,
TagException,
ReadOnlyFileException,
InvalidAudioFrameException
f - The file to read.
CannotReadException - If the file could not be read, the extension wasn't
recognized, or an IO error occurred during the read.
TagException
ReadOnlyFileException
java.io.IOException
InvalidAudioFrameException
public static void write(AudioFile f)
throws CannotWriteException
f - The AudioFile to be written
CannotWriteException - If the file could not be written/accessed, the extension
wasn't recognized, or other IO error occurred.public void addAudioFileModificationListener(AudioFileModificationListener listener)
listener - listener
public void deleteTag(AudioFile f)
throws CannotReadException,
CannotWriteException
f - The file where the tag will be deleted
CannotWriteException - If the file could not be written/accessed, the extension
wasn't recognized, or other IO error occurred.
CannotReadExceptionprivate void prepareReadersAndWriters()
public AudioFile readFile(java.io.File f)
throws CannotReadException,
java.io.IOException,
TagException,
ReadOnlyFileException,
InvalidAudioFrameException
f - The file to read.
CannotReadException - If the file could not be read, the extension wasn't
recognized, or an IO error occurred during the read.
TagException
ReadOnlyFileException
java.io.IOException
InvalidAudioFrameException
public void checkFileExists(java.io.File file)
throws java.io.FileNotFoundException
file -
java.io.FileNotFoundExceptionpublic void removeAudioFileModificationListener(AudioFileModificationListener listener)
listener - listener
public void writeFile(AudioFile f)
throws CannotWriteException
f - The AudioFile to be written
CannotWriteException - If the file could not be written/accessed, the extension
wasn't recognized, or other IO error occurred.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||