|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jaudiotagger.audio.mp3.MP3AudioHeader
public final class MP3AudioHeader
Represents the audio header of an MP3 File
The audio header consists of a number of audio frames. Because we are not trying to play the audio but only extract some information regarding the audio we only need to read the first audio frames to ensure that we have correctly identified them as audio frames and extracted the metadata we reuire.
Start of Audio id 0xFF (11111111) and then second byte anded with 0xE0(11100000). For example 2nd byte doesnt have to be 0xE0 is just has to have the top 3 signicant bits set. For example 0xFB (11111011) is a common occurence of the second match. The 2nd byte defines flags to indicate various mp3 values.
Having found these two values we then read the header which comprises these two bytes plus a further two to ensure this really is a MP3Header, sometimes the first frame is actually a dummy frame with summary information held within about the whole file, typically using a Xing Header or LAme Header. This is most useful when the file is variable bit rate, if the file is variable bit rate but does not use a summary header it will not be correctly identified as a VBR frame and the track length will be incorreclty calculated. Strictly speaking MP3 means an MPEG-1, Layer III file but MP2 (MPEG-1,Layer II), MP1 (MPEG-1,Layer I) and MPEG-2 files are sometimes used and named with the .mp3 suffix so this library attempts to supports all these formats.
Field Summary | |
---|---|
static java.util.logging.Logger |
logger
|
Constructor Summary | |
---|---|
MP3AudioHeader(java.io.File seekFile)
Search for the first MP3Header in the file The search starts from the start of the file, it is usually safer to use the alternative constructor that allows you to provide the length of the tag header as a parameter so the tag can be skipped over. |
|
MP3AudioHeader(java.io.File seekFile,
long startByte)
Search for the first MP3Header in the file Starts searching from location startByte, this is because there is likely to be an ID3TagHeader before the start of the audio. |
Method Summary | |
---|---|
java.lang.String |
getBitRate()
|
long |
getBitRateAsNumber()
|
java.lang.String |
getChannels()
|
java.lang.String |
getEmphasis()
|
java.lang.String |
getEncoder()
|
java.lang.String |
getEncodingType()
|
java.lang.String |
getFormat()
|
long |
getMp3StartByte()
Returns the byte position of the first MP3 Frame that the file arguement refers to. |
java.lang.String |
getMpegLayer()
|
java.lang.String |
getMpegVersion()
|
long |
getNumberOfFrames()
|
long |
getNumberOfFramesEstimate()
|
double |
getPreciseTrackLength()
|
java.lang.String |
getSampleRate()
|
int |
getSampleRateAsNumber()
|
int |
getTrackLength()
|
java.lang.String |
getTrackLengthAsString()
Return the length in user friendly format |
boolean |
isCopyrighted()
|
boolean |
isOriginal()
|
boolean |
isPadding()
|
boolean |
isPrivate()
|
boolean |
isProtected()
|
boolean |
isVariableBitRate()
|
boolean |
seek(java.io.File seekFile,
long startByte)
Returns true if the first MP3 frame can be found for the MP3 file This is the first byte of music data and not the ID3 Tag Frame. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static java.util.logging.Logger logger
Constructor Detail |
---|
public MP3AudioHeader(java.io.File seekFile) throws java.io.IOException, InvalidAudioFrameException
seekFile
-
java.io.IOException
InvalidAudioFrameException
public MP3AudioHeader(java.io.File seekFile, long startByte) throws java.io.IOException, InvalidAudioFrameException
seekFile
- startByte
-
java.io.IOException
InvalidAudioFrameException
Method Detail |
---|
public boolean seek(java.io.File seekFile, long startByte) throws java.io.IOException
seekFile
- MP3 file to seekstartByte
- if there is an ID3v2tag we dont want to start reading from the start of the tag
java.io.IOException
- on any I/O errorpublic long getMp3StartByte()
file
arguement refers to. This is the first byte of music
data and not the ID3 Tag Frame.
public long getNumberOfFrames()
public long getNumberOfFramesEstimate()
public double getPreciseTrackLength()
public int getTrackLength()
getTrackLength
in interface AudioHeader
public java.lang.String getTrackLengthAsString()
public java.lang.String getEncodingType()
getEncodingType
in interface AudioHeader
public long getBitRateAsNumber()
getBitRateAsNumber
in interface AudioHeader
public java.lang.String getBitRate()
getBitRate
in interface AudioHeader
public int getSampleRateAsNumber()
getSampleRateAsNumber
in interface AudioHeader
public java.lang.String getSampleRate()
getSampleRate
in interface AudioHeader
public java.lang.String getMpegVersion()
public java.lang.String getMpegLayer()
public java.lang.String getFormat()
getFormat
in interface AudioHeader
public java.lang.String getChannels()
getChannels
in interface AudioHeader
public java.lang.String getEmphasis()
public boolean isVariableBitRate()
isVariableBitRate
in interface AudioHeader
public boolean isProtected()
public boolean isPrivate()
public boolean isCopyrighted()
public boolean isOriginal()
public boolean isPadding()
public java.lang.String getEncoder()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |