public class MP3AudioInputStream extends AudioInputStream
AudioInputStream adapter for MP3ElementaryInputStream.
Unlike a regular audio input stream, an MP3 audio input stream can have a variable frame size and can change its encoding method in mid-stream. Therefore method getFormat can return different values for each frame, and mark/reset is not supported, and method getFrameLength can not return the total number of frames in the stream.
format, frameLength, framePos, frameSize| Constructor and Description |
|---|
MP3AudioInputStream(File file)
Creates an MP3AudioInputStream and reads the stream until the first
frame is reached.
|
MP3AudioInputStream(InputStream in)
Creates an MP3AudioInputStream and reads the stream until the first
frame is reached.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
AudioFormat |
getFormat()
Returns the format of the next frame.
|
long |
getFrameLength()
Returns -1 because we don't know how many frames the stream has.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read()
Throws an IOException, because the frame size is greater than 1.
|
int |
read(byte[] b,
int off,
int len)
Reads some number of bytes from the audio input stream and stores them
into the buffer array b.
|
void |
reset() |
long |
skip(long n) |
readpublic MP3AudioInputStream(File file) throws IOException
file - A File.IOException - if the file does not contain an MP3 elementary stream.public MP3AudioInputStream(InputStream in) throws IOException
in - An InputStream.IOException - if the stream does not contain an MP3 elementary stream.public int available()
throws IOException
available in class AudioInputStreamIOExceptionpublic AudioFormat getFormat()
getFormat in class AudioInputStreampublic long getFrameLength()
getFrameLength in class AudioInputStreampublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class AudioInputStreamIOExceptionpublic int read()
throws IOException
read in class AudioInputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
b.length - (b.length % frameSize) bytes will be read.read in class AudioInputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class AudioInputStreamIOExceptionpublic void mark(int readlimit)
mark in class AudioInputStreampublic boolean markSupported()
markSupported in class AudioInputStreampublic void reset()
throws IOException
reset in class AudioInputStreamIOExceptionCopyright © 2014. All Rights Reserved.