public class MP3File extends AudioFile
Modifier and Type | Field and Description |
---|---|
private ID3v1Tag |
id3v1tag
The ID3v1 tag that this file contains.
|
private ID3v24Tag |
id3v2Asv24tag
Representation of the idv2 tag as a idv24 tag
|
private AbstractID3v2Tag |
id3v2tag
the ID3v2 tag that this file contains.
|
static int |
LOAD_ALL |
static int |
LOAD_IDV1TAG |
static int |
LOAD_IDV2TAG |
static int |
LOAD_LYRICS3
This option is currently ignored
|
private AbstractLyrics3 |
lyrics3tag
The Lyrics3 tag that this file contains.
|
private static int |
MINIMUM_FILESIZE |
protected static AbstractTagDisplayFormatter |
tagFormatter |
audioHeader, file, logger, tag
Constructor and Description |
---|
MP3File()
Creates a new empty MP3File datatype that is not associated with a
specific file.
|
MP3File(java.io.File file)
Creates a new MP3File datatype and parse the tag from the given file
Object.
|
MP3File(java.io.File file,
int loadOptions)
Creates a new MP3File dataType and parse the tag from the given file
Object, files must be writable to use this constructor.
|
MP3File(java.io.File file,
int loadOptions,
boolean readOnly)
Creates a new MP3File dataType and parse the tag from the given file
Object, files can be opened read only if required.
|
MP3File(java.lang.String filename)
Creates a new MP3File datatype and parse the tag from the given filename.
|
Modifier and Type | Method and Description |
---|---|
private MP3AudioHeader |
checkAudioStart(long startByte,
MP3AudioHeader firstHeaderAfterTag)
Regets the audio header starting from start of file, and write appropriate logging to indicate
potential problem to user.
|
void |
commit()
Overridden for compatibility with merged code
|
Tag |
convertTag(Tag tag,
ID3V2Version id3V2Version)
Convert tag from current version to another as specified by id3V2Version
|
Tag |
createDefaultTag()
Create Default Tag
|
private static void |
createPlainTextStructureFormatter() |
private static void |
createXMLStructureFormatter() |
void |
delete(AbstractTag mp3tag)
Remove tag from file
|
java.lang.String |
displayStructureAsPlainText()
Displays MP3File Structure
|
java.lang.String |
displayStructureAsXML()
Displays MP3File Structure
|
java.io.File |
extractID3v2TagDataIntoFile(java.io.File outputFile)
Extracts the raw ID3v2 tag data into a file.
|
ID3v1Tag |
getID3v1Tag()
Returns the
ID3v1 tag for this dataType. |
AbstractID3v2Tag |
getID3v2Tag()
Returns the
ID3v2 tag for this datatype. |
ID3v24Tag |
getID3v2TagAsv24() |
MP3AudioHeader |
getMP3AudioHeader()
Return audio header
|
long |
getMP3StartByte(java.io.File file)
Used by tags when writing to calculate the location of the music file
|
static AbstractTagDisplayFormatter |
getStructureFormatter() |
Tag |
getTagAndConvertOrCreateAndSetDefault()
Get the ID3v2 tag and convert to preferred version or if the file doesn't have one at all
create a default tag of preferred version and set it.
|
Tag |
getTagOrCreateDefault()
Overidden to only consider ID3v2 Tag
|
boolean |
hasID3v1Tag()
Returns true if this datatype contains an
Id3v1 tag |
boolean |
hasID3v2Tag()
Returns true if this datatype contains an
Id3v2 tag |
private boolean |
isFilePortionNull(int startByte,
int endByte) |
void |
precheck(java.io.File file)
Check can write to file
|
private void |
readLyrics3Tag(java.io.File file,
java.io.RandomAccessFile newFile,
int loadOptions)
Read lyrics3 Tag
TODO:not working
|
private void |
readV1Tag(java.io.File file,
java.io.RandomAccessFile newFile,
int loadOptions)
Read v1 tag
|
private void |
readV2Tag(java.io.File file,
int loadOptions,
int startByte)
Read V2tag if exists
TODO:shouldn't we be handing TagExceptions:when will they be thrown
|
void |
save()
Saves the tags in this dataType to the file referred to by this dataType.
|
void |
save(java.io.File fileToSave)
Saves the tags in this dataType to the file argument.
|
void |
setID3v1Tag(AbstractTag mp3tag)
Sets the
ID3v1 tag for this dataType. |
void |
setID3v1Tag(ID3v1Tag id3v1tag)
Sets the ID3v1(_1)tag to the tag provided as an argument.
|
void |
setID3v1Tag(Tag id3v1tag) |
void |
setID3v2Tag(AbstractID3v2Tag id3v2tag)
Sets the v2 tag to the v2 tag provided as an argument.
|
void |
setID3v2Tag(AbstractTag mp3tag)
Sets the
ID3v2 tag for this dataType. |
void |
setID3v2TagOnly(AbstractID3v2Tag id3v2tag)
Set v2 tag ,don't need to set v24 tag because saving
|
void |
setTag(Tag tag)
Set the Tag
If the parameter tag is a v1tag then the v1 tag is set if v2tag then the v2tag.
|
checkFileExists, checkFilePermissions, getAudioHeader, getBaseFilename, getFile, getTag, getTagOrCreateAndSetDefault, setFile, toString
private static final int MINIMUM_FILESIZE
protected static AbstractTagDisplayFormatter tagFormatter
private AbstractID3v2Tag id3v2tag
private ID3v24Tag id3v2Asv24tag
private AbstractLyrics3 lyrics3tag
private ID3v1Tag id3v1tag
public static final int LOAD_IDV1TAG
public static final int LOAD_IDV2TAG
public static final int LOAD_LYRICS3
public static final int LOAD_ALL
public MP3File()
public MP3File(java.lang.String filename) throws java.io.IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException
filename
- MP3 filejava.io.IOException
- on any I/O errorTagException
- on any exception generated by this library.ReadOnlyFileException
InvalidAudioFrameException
public MP3File(java.io.File file, int loadOptions) throws java.io.IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException
file
- MP3 fileloadOptions
- decide what tags to loadjava.io.IOException
- on any I/O errorTagException
- on any exception generated by this library.ReadOnlyFileException
InvalidAudioFrameException
public MP3File(java.io.File file, int loadOptions, boolean readOnly) throws java.io.IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException
file
- MP3 fileloadOptions
- decide what tags to loadreadOnly
- causes the files to be opened readonlyjava.io.IOException
- on any I/O errorTagException
- on any exception generated by this library.ReadOnlyFileException
InvalidAudioFrameException
public MP3File(java.io.File file) throws java.io.IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException
file
- MP3 filejava.io.IOException
- on any I/O errorTagException
- on any exception generated by this library.ReadOnlyFileException
InvalidAudioFrameException
private void readV1Tag(java.io.File file, java.io.RandomAccessFile newFile, int loadOptions) throws java.io.IOException
file
- newFile
- loadOptions
- java.io.IOException
private void readV2Tag(java.io.File file, int loadOptions, int startByte) throws java.io.IOException, TagException
file
- loadOptions
- java.io.IOException
TagException
private void readLyrics3Tag(java.io.File file, java.io.RandomAccessFile newFile, int loadOptions) throws java.io.IOException
file
- newFile
- loadOptions
- java.io.IOException
private boolean isFilePortionNull(int startByte, int endByte) throws java.io.IOException
startByte
- endByte
- java.lang.Exception
java.io.IOException
private MP3AudioHeader checkAudioStart(long startByte, MP3AudioHeader firstHeaderAfterTag) throws java.io.IOException, InvalidAudioFrameException
startByte
- firstHeaderAfterTag
- java.io.IOException
InvalidAudioFrameException
public long getMP3StartByte(java.io.File file) throws InvalidAudioFrameException, java.io.IOException
file
- java.io.IOException
InvalidAudioFrameException
public java.io.File extractID3v2TagDataIntoFile(java.io.File outputFile) throws TagNotFoundException, java.io.IOException
outputFile
- to write the data toTagNotFoundException
java.io.IOException
public MP3AudioHeader getMP3AudioHeader()
public boolean hasID3v1Tag()
Id3v1
tagId3v1
tagpublic boolean hasID3v2Tag()
Id3v2
tagId3v2
tagpublic void setID3v1Tag(ID3v1Tag id3v1tag)
id3v1tag
- public void setID3v1Tag(Tag id3v1tag)
public void setID3v1Tag(AbstractTag mp3tag)
ID3v1
tag for this dataType. A new
ID3v1_1
dataType is created from the argument and then used
here.mp3tag
- Any MP3Tag dataType can be used and will be converted into a
new ID3v1_1 dataType.public ID3v1Tag getID3v1Tag()
ID3v1
tag for this dataType.ID3v1
tag for this dataTypepublic void setID3v2Tag(AbstractTag mp3tag)
ID3v2
tag for this dataType. A new
ID3v2_4
dataType is created from the argument and then used
here.mp3tag
- Any MP3Tag dataType can be used and will be converted into a
new ID3v2_4 dataType.public void setID3v2Tag(AbstractID3v2Tag id3v2tag)
id3v2tag
- public void setID3v2TagOnly(AbstractID3v2Tag id3v2tag)
id3v2tag
- public AbstractID3v2Tag getID3v2Tag()
ID3v2
tag for this datatype.ID3v2
tag for this datatypepublic ID3v24Tag getID3v2TagAsv24()
public void delete(AbstractTag mp3tag) throws java.io.FileNotFoundException, java.io.IOException
mp3tag
- java.io.FileNotFoundException
java.io.IOException
public void save() throws java.io.IOException, TagException
java.io.IOException
- on any I/O errorTagException
- on any exception generated by this library.public void commit() throws CannotWriteException
commit
in class AudioFile
CannotWriteException
AudioFileIO
public void precheck(java.io.File file) throws java.io.IOException
file
- java.io.IOException
public void save(java.io.File fileToSave) throws java.io.IOException
fileToSave
- file to save the this dataTypes tags tojava.io.FileNotFoundException
- if unable to find filejava.io.IOException
- on any I/O errorpublic java.lang.String displayStructureAsXML()
displayStructureAsXML
in class AudioFile
public java.lang.String displayStructureAsPlainText()
displayStructureAsPlainText
in class AudioFile
private static void createXMLStructureFormatter()
private static void createPlainTextStructureFormatter()
public static AbstractTagDisplayFormatter getStructureFormatter()
public void setTag(Tag tag)
public Tag createDefaultTag()
createDefaultTag
in class AudioFile
public Tag convertTag(Tag tag, ID3V2Version id3V2Version)
public Tag getTagOrCreateDefault()
getTagOrCreateDefault
in class AudioFile
public Tag getTagAndConvertOrCreateAndSetDefault()
getTagAndConvertOrCreateAndSetDefault
in class AudioFile
Copyright © 2005-2013 java.net. All Rights Reserved.