|
Copyright 2012-04-26 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
javax.sound.sampled.AudioInputStream
org.monte.media.mp3.MP3AudioInputStream
public class MP3AudioInputStream
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.
| Field Summary |
|---|
| Fields inherited from class javax.sound.sampled.AudioInputStream |
|---|
format, frameLength, framePos, frameSize |
| Constructor Summary | |
|---|---|
MP3AudioInputStream(java.io.File file)
Creates an MP3AudioInputStream and reads the stream until the first frame is reached. |
|
MP3AudioInputStream(java.io.InputStream in)
Creates an MP3AudioInputStream and reads the stream until the first frame is reached. |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
close()
|
javax.sound.sampled.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)
|
| Methods inherited from class javax.sound.sampled.AudioInputStream |
|---|
read |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MP3AudioInputStream(java.io.File file)
throws java.io.IOException
file - A File.
java.io.IOException - if the file does not contain an MP3 elementary stream.
public MP3AudioInputStream(java.io.InputStream in)
throws java.io.IOException
in - An InputStream.
java.io.IOException - if the stream does not contain an MP3 elementary stream.| Method Detail |
|---|
public int available()
throws java.io.IOException
available in class javax.sound.sampled.AudioInputStreamjava.io.IOExceptionpublic javax.sound.sampled.AudioFormat getFormat()
getFormat in class javax.sound.sampled.AudioInputStreampublic long getFrameLength()
getFrameLength in class javax.sound.sampled.AudioInputStream
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class javax.sound.sampled.AudioInputStreamjava.io.IOException
public int read()
throws java.io.IOException
read in class javax.sound.sampled.AudioInputStreamjava.io.IOException
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
b.length - (b.length % frameSize) bytes will be read.
read in class javax.sound.sampled.AudioInputStreamjava.io.IOException
public long skip(long n)
throws java.io.IOException
skip in class javax.sound.sampled.AudioInputStreamjava.io.IOExceptionpublic void mark(int readlimit)
mark in class javax.sound.sampled.AudioInputStreampublic boolean markSupported()
markSupported in class javax.sound.sampled.AudioInputStream
public void reset()
throws java.io.IOException
reset in class javax.sound.sampled.AudioInputStreamjava.io.IOException
|
Copyright 2012-04-26 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||