entagged.audioformats
Class AudioFileIO

java.lang.Object
  extended byentagged.audioformats.AudioFileIO

public class AudioFileIO
extends java.lang.Object

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().getArtist(); //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.

Since:
v0.01
Version:
$Id: AudioFileIO.html,v 1.1 2007/03/23 14:18:25 nicov1 Exp $
Author:
Raphael Slinckx
See Also:
AudioFile, Tag

Constructor Summary
AudioFileIO()
          Creates an instance.
 
Method Summary
 void addAudioFileModificationListener(entagged.audioformats.generic.AudioFileModificationListener listener)
          Adds an listener for all file formats.
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 isntance for static use.
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(entagged.audioformats.generic.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
 

Constructor Detail

AudioFileIO

public AudioFileIO()
Creates an instance.

Method Detail

delete

public static void delete(AudioFile f)
                   throws entagged.audioformats.exceptions.CannotWriteException

Delete the tag, if any, contained in the given file.

Parameters:
f - The file where the tag will be deleted
Throws:
entagged.audioformats.exceptions.CannotWriteException - If the file could not be written/accessed, the extension wasn't recognized, or other IO error occured.

getDefaultAudioFileIO

public static AudioFileIO getDefaultAudioFileIO()
This method returns the default isntance for static use.

Returns:
The default instance.

read

public static AudioFile read(java.io.File f)
                      throws entagged.audioformats.exceptions.CannotReadException

Read the tag contained in the given file.

Parameters:
f - The file to read.
Returns:
The AudioFile with the file tag and the file encoding infos.
Throws:
entagged.audioformats.exceptions.CannotReadException - If the file could not be read, the extension wasn't recognized, or an IO error occured during the read.

write

public static void write(AudioFile f)
                  throws entagged.audioformats.exceptions.CannotWriteException

Write the tag contained in the audiofile in the actual file on the disk.

Parameters:
f - The AudioFile to be written
Throws:
entagged.audioformats.exceptions.CannotWriteException - If the file could not be written/accessed, the extension wasn't recognized, or other IO error occured.

addAudioFileModificationListener

public void addAudioFileModificationListener(entagged.audioformats.generic.AudioFileModificationListener listener)
Adds an listener for all file formats.

Parameters:
listener - listener

deleteTag

public void deleteTag(AudioFile f)
               throws entagged.audioformats.exceptions.CannotWriteException

Delete the tag, if any, contained in the given file.

Parameters:
f - The file where the tag will be deleted
Throws:
entagged.audioformats.exceptions.CannotWriteException - If the file could not be written/accessed, the extension wasn't recognized, or other IO error occured.

readFile

public AudioFile readFile(java.io.File f)
                   throws entagged.audioformats.exceptions.CannotReadException

Read the tag contained in the given file.

Parameters:
f - The file to read.
Returns:
The AudioFile with the file tag and the file encoding infos.
Throws:
entagged.audioformats.exceptions.CannotReadException - If the file could not be read, the extension wasn't recognized, or an IO error occured during the read.

removeAudioFileModificationListener

public void removeAudioFileModificationListener(entagged.audioformats.generic.AudioFileModificationListener listener)
Removes an listener for all file formats.

Parameters:
listener - listener

writeFile

public void writeFile(AudioFile f)
               throws entagged.audioformats.exceptions.CannotWriteException

Write the tag contained in the audiofile in the actual file on the disk.

Parameters:
f - The AudioFile to be written
Throws:
entagged.audioformats.exceptions.CannotWriteException - If the file could not be written/accessed, the extension wasn't recognized, or other IO error occured.