public class AudioFile
extends java.lang.Object
This is the main object manipulated by the user representing an audiofile, its properties and its tag.
The prefered way to obtain an AudioFile
is to use the AudioFileIO.read(File)
method.
The AudioFile
contains every properties associated with the file itself (no meta-data), like the bitrate, the sampling rate, the encoding audioHeaders, etc.
To get the meta-data contained in this file you have to get the Tag
of this AudioFile
AudioFileIO
,
Tag
Modifier and Type | Field and Description |
---|---|
protected AudioHeader |
audioHeader
The Audio header info
|
protected java.io.File |
file
The physical file that this instance represents.
|
static java.util.logging.Logger |
logger |
protected Tag |
tag
The tag
|
Constructor and Description |
---|
AudioFile() |
AudioFile(java.io.File f,
AudioHeader audioHeader,
Tag tag)
These constructors are used by the different readers, users should not use them, but use the
AudioFileIO.read(File) method instead !. |
AudioFile(java.lang.String s,
AudioHeader audioHeader,
Tag tag)
These constructors are used by the different readers, users should not use them, but use the
AudioFileIO.read(File) method instead !. |
Modifier and Type | Method and Description |
---|---|
void |
checkFileExists(java.io.File file)
Check does file exist
|
protected java.io.RandomAccessFile |
checkFilePermissions(java.io.File file,
boolean readOnly)
Checks the file is accessible with the correct permissions, otherwise exception occurs
|
void |
commit()
Write the tag contained in this AudioFile in the actual file on the disk, this is the same as calling the
AudioFileIO.write(this) method. |
Tag |
createDefaultTag()
Create Default Tag
|
java.lang.String |
displayStructureAsPlainText()
Optional debugging method.
|
java.lang.String |
displayStructureAsXML()
Optional debugging method.
|
AudioHeader |
getAudioHeader()
Return audio header information
|
static java.lang.String |
getBaseFilename(java.io.File file) |
java.io.File |
getFile()
Retrieve the physical file
|
Tag |
getTag()
Returns the tag contained in this AudioFile, the
Tag contains any useful meta-data, like
artist, album, title, etc. |
Tag |
getTagAndConvertOrCreateAndSetDefault() |
Tag |
getTagOrCreateAndSetDefault()
Get the tag or if the file doesn't have one at all, create a default tag and set it
|
Tag |
getTagOrCreateDefault()
Get the tag or if the file doesn't have one at all, create a default tag and return
|
void |
setFile(java.io.File file)
Set the file to store the info in
|
void |
setTag(Tag tag)
Assign a tag to this audio file
|
java.lang.String |
toString()
Returns a multi-line string with the file path, the encoding audioHeader, and the tag contents.
|
public static java.util.logging.Logger logger
protected java.io.File file
protected AudioHeader audioHeader
protected Tag tag
public AudioFile()
public AudioFile(java.io.File f, AudioHeader audioHeader, Tag tag)
These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File)
method instead !.
Create the AudioFile representing file f, the encoding audio headers and containing the tag
f
- The file of the audio fileaudioHeader
- the encoding audioHeaders over this filetag
- the tag contained in this file or null if no tag existspublic AudioFile(java.lang.String s, AudioHeader audioHeader, Tag tag)
These constructors are used by the different readers, users should not use them, but use the AudioFileIO.read(File)
method instead !.
Create the AudioFile representing file denoted by pathnames, the encoding audio Headers and containing the tag
s
- The pathname of the audio fileaudioHeader
- the encoding audioHeaders over this filetag
- the tag contained in this filepublic void commit() throws CannotWriteException
Write the tag contained in this AudioFile in the actual file on the disk, this is the same as calling the AudioFileIO.write(this)
method.
CannotWriteException
- If the file could not be written/accessed, the extension wasn't recognized, or other IO error occured.AudioFileIO
public void setFile(java.io.File file)
file
- public java.io.File getFile()
public void setTag(Tag tag)
tag
- Tag to be assignedpublic AudioHeader getAudioHeader()
public Tag getTag()
Returns the tag contained in this AudioFile, the Tag
contains any useful meta-data, like
artist, album, title, etc. If the file does not contain any tag the null is returned. Some audio formats do
not allow there to be no tag so in this case the reader would return an empty tag whereas for others such
as mp3 it is purely optional.
public java.lang.String toString()
Returns a multi-line string with the file path, the encoding audioHeader, and the tag contents.
toString
in class java.lang.Object
public void checkFileExists(java.io.File file) throws java.io.FileNotFoundException
file
- java.io.FileNotFoundException
- if file not foundprotected java.io.RandomAccessFile checkFilePermissions(java.io.File file, boolean readOnly) throws ReadOnlyFileException, java.io.FileNotFoundException
file
- readOnly
- ReadOnlyFileException
java.io.FileNotFoundException
public java.lang.String displayStructureAsXML()
public java.lang.String displayStructureAsPlainText()
public Tag createDefaultTag()
public Tag getTagOrCreateDefault()
public Tag getTagOrCreateAndSetDefault()
public Tag getTagAndConvertOrCreateAndSetDefault()
public static java.lang.String getBaseFilename(java.io.File file)
file
- Copyright © 2005-2013 java.net. All Rights Reserved.