public class MP3File extends AudioFile
Modifier and Type | Field and Description |
---|---|
static int |
LOAD_ALL |
static int |
LOAD_IDV1TAG |
static int |
LOAD_IDV2TAG |
static int |
LOAD_LYRICS3
This option is currently ignored
|
protected static AbstractTagDisplayFormatter |
tagFormatter |
Constructor and Description |
---|
MP3File()
Creates a new empty MP3File datatype that is not associated with a
specific file.
|
MP3File(File file)
Creates a new MP3File datatype and parse the tag from the given file
Object.
|
MP3File(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(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(String filename)
Creates a new MP3File datatype and parse the tag from the given filename.
|
Modifier and Type | Method and Description |
---|---|
void |
commit()
Overridden for compatibility with merged code
|
Tag |
createDefaultTag()
Create Default Tag
|
void |
delete(AbstractTag mp3tag)
Remove tag from file
|
String |
displayStructureAsPlainText()
Displays MP3File Structure
|
String |
displayStructureAsXML()
Displays MP3File Structure
|
File |
extractID3v2TagDataIntoFile(File outputFile)
Extracts the raw ID3v2 tag data into a file.
|
byte[] |
getHash()
Calculates hash with algorithm "MD5".
|
byte[] |
getHash(int buffer)
Calculates hash with given buffer size.
|
byte[] |
getHash(String algorithm)
Calculates hash with given algorithm.
|
byte[] |
getHash(String algorithm,
int bufferSize)
Calculates hash with algorithm "MD5", "SHA-1" or SHA-256".
|
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(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 and set as the current tag
|
Tag |
getTagAndConvertOrCreateDefault()
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()
Overridden 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 |
void |
precheck(File file)
Check can write to file
|
void |
save()
Saves the tags in this dataType to the file referred to by this dataType.
|
void |
save(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, convertID3Tag, delete, getAudioHeader, getBaseFilename, getExt, getFile, getTag, getTagOrCreateAndSetDefault, setExt, setFile, toString
protected static AbstractTagDisplayFormatter tagFormatter
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(String filename) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException
filename
- MP3 fileIOException
- on any I/O errorTagException
- on any exception generated by this library.ReadOnlyFileException
InvalidAudioFrameException
CannotReadException
public MP3File(File file, int loadOptions) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException
file
- MP3 fileloadOptions
- decide what tags to loadIOException
- on any I/O errorTagException
- on any exception generated by this library.ReadOnlyFileException
InvalidAudioFrameException
CannotReadException
public MP3File(File file, int loadOptions, boolean readOnly) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException
file
- MP3 fileloadOptions
- decide what tags to loadreadOnly
- causes the files to be opened readonlyIOException
- on any I/O errorTagException
- on any exception generated by this library.ReadOnlyFileException
InvalidAudioFrameException
CannotReadException
public MP3File(File file) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException
file
- MP3 fileIOException
- on any I/O errorTagException
- on any exception generated by this library.ReadOnlyFileException
InvalidAudioFrameException
CannotReadException
public long getMP3StartByte(File file) throws InvalidAudioFrameException, IOException
file
- IOException
InvalidAudioFrameException
public File extractID3v2TagDataIntoFile(File outputFile) throws TagNotFoundException, IOException
outputFile
- to write the data toTagNotFoundException
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 byte[] getHash(String algorithm) throws NoSuchAlgorithmException, InvalidAudioFrameException, IOException
algorithm
- options MD5,SHA-1,SHA-256IOException
InvalidAudioFrameException
NoSuchAlgorithmException
public byte[] getHash(int buffer) throws NoSuchAlgorithmException, InvalidAudioFrameException, IOException
buffer
- IOException
InvalidAudioFrameException
NoSuchAlgorithmException
public byte[] getHash() throws NoSuchAlgorithmException, InvalidAudioFrameException, IOException
IOException
InvalidAudioFrameException
NoSuchAlgorithmException
public byte[] getHash(String algorithm, int bufferSize) throws InvalidAudioFrameException, IOException, NoSuchAlgorithmException
IOException
InvalidAudioFrameException
NoSuchAlgorithmException
public 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 FileNotFoundException, IOException
mp3tag
- FileNotFoundException
IOException
public void save() throws IOException, TagException
IOException
- on any I/O errorTagException
- on any exception generated by this library.public void commit() throws CannotWriteException
commit
in class AudioFile
NoWritePermissionsException
- if the file could not be written to due to file permissionsCannotWriteException
AudioFileIO
public void precheck(File file) throws IOException
file
- IOException
public void save(File fileToSave) throws IOException
fileToSave
- file to save the this dataTypes tags toFileNotFoundException
- if unable to find fileIOException
- on any I/O errorpublic String displayStructureAsXML()
displayStructureAsXML
in class AudioFile
public String displayStructureAsPlainText()
displayStructureAsPlainText
in class AudioFile
public static AbstractTagDisplayFormatter getStructureFormatter()
public void setTag(Tag tag)
public Tag createDefaultTag()
createDefaultTag
in class AudioFile
public Tag getTagOrCreateDefault()
getTagOrCreateDefault
in class AudioFile
public Tag getTagAndConvertOrCreateDefault()
getTagAndConvertOrCreateDefault
in class AudioFile
public Tag getTagAndConvertOrCreateAndSetDefault()
getTagAndConvertOrCreateAndSetDefault
in class AudioFile
Copyright © 2005–2020 jthink.net. All rights reserved.