|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javazoom.jlgui.basicplayer.BasicPlayer
public class BasicPlayer
BasicPlayer is a threaded simple player class based on JavaSound API. It has been successfully tested under J2SE 1.3.x, 1.4.x and 1.5.x.
Field Summary | |
---|---|
protected int |
encodedLength
|
static int |
EXTERNAL_BUFFER_SIZE
|
protected javax.sound.sampled.AudioFileFormat |
m_audioFileFormat
|
protected javax.sound.sampled.AudioInputStream |
m_audioInputStream
|
protected java.lang.Object |
m_dataSource
|
protected javax.sound.sampled.AudioInputStream |
m_encodedaudioInputStream
|
protected javax.sound.sampled.FloatControl |
m_gainControl
|
protected javax.sound.sampled.SourceDataLine |
m_line
|
protected java.lang.String |
m_mixerName
|
protected javax.sound.sampled.FloatControl |
m_panControl
|
protected java.lang.Thread |
m_thread
|
static int |
OPENED
|
static int |
PAUSED
|
static int |
PLAYING
|
static int |
SEEKING
|
static int |
SKIP_INACCURACY_SIZE
|
static int |
STOPPED
|
static int |
UNKNOWN
These variables are used to distinguish stopped, paused, playing states. |
Constructor Summary | |
---|---|
BasicPlayer()
Constructs a Basic Player. |
Method Summary | |
---|---|
void |
addBasicPlayerListener(BasicPlayerListener bpl)
Add listener to be notified. |
protected void |
closeStream()
|
protected void |
createLine()
Inits a DateLine. |
protected java.util.Map |
deepCopy(java.util.Map src)
Deep copy of a Map. |
protected int |
getEncodedStreamPosition()
|
float |
getGainValue()
Returns Gain value. |
int |
getLineBufferSize()
Return SourceDataLine buffer size. |
int |
getLineCurrentBufferSize()
Return SourceDataLine current buffer size. |
java.util.Collection |
getListeners()
Return registered listeners. |
float |
getMaximumGain()
Gets max Gain value. |
float |
getMinimumGain()
Gets min Gain value. |
javax.sound.sampled.Mixer |
getMixer(java.lang.String name)
|
java.lang.String |
getMixerName()
|
java.util.List |
getMixers()
|
float |
getPan()
Returns Pan value. |
float |
getPrecision()
Returns Pan precision. |
long |
getSleepTime()
Return thread sleep time in milliseconds. |
int |
getStatus()
Returns BasicPlayer status. |
boolean |
hasGainControl()
Returns true if Gain control is supported. |
boolean |
hasPanControl()
Returns true if Pan control is supported. |
protected void |
initAudioInputStream()
Inits AudioInputStream and AudioFileFormat from the data source. |
protected void |
initAudioInputStream(java.io.File file)
Inits Audio ressources from file. |
protected void |
initAudioInputStream(java.io.InputStream inputStream)
Inits Audio ressources from InputStream. |
protected void |
initAudioInputStream(java.net.URL url)
Inits Audio ressources from URL. |
protected void |
initLine()
Inits Audio ressources from AudioSystem. |
protected void |
notifyEvent(int code,
int position,
double value,
java.lang.Object description)
Notify listeners about a BasicPlayerEvent. |
void |
open(java.io.File file)
Open file to play. |
void |
open(java.io.InputStream inputStream)
Open inputstream to play. |
void |
open(java.net.URL url)
Open URL to play. |
protected void |
openLine()
Opens the line. |
void |
pause()
Pause playback. |
protected void |
pausePlayback()
Pauses the playback. |
void |
play()
Start playback. |
void |
removeBasicPlayerListener(BasicPlayerListener bpl)
Remove registered listener. |
protected void |
reset()
|
void |
resume()
Resume playback. |
protected void |
resumePlayback()
Resumes the playback. |
void |
run()
Main loop. |
long |
seek(long bytes)
Skip bytes. |
void |
setGain(double fGain)
Sets Gain value. |
void |
setLineBufferSize(int size)
Set SourceDataLine buffer size. |
void |
setMixerName(java.lang.String name)
|
void |
setPan(double fPan)
Sets Pan value. |
void |
setSleepTime(long time)
Set thread sleep time. |
protected long |
skipBytes(long bytes)
Skip bytes in the File inputstream. |
protected void |
startPlayback()
Starts playback. |
void |
stop()
Stop playback. |
protected void |
stopPlayback()
Stops the playback. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static int EXTERNAL_BUFFER_SIZE
public static int SKIP_INACCURACY_SIZE
protected java.lang.Thread m_thread
protected java.lang.Object m_dataSource
protected javax.sound.sampled.AudioInputStream m_encodedaudioInputStream
protected int encodedLength
protected javax.sound.sampled.AudioInputStream m_audioInputStream
protected javax.sound.sampled.AudioFileFormat m_audioFileFormat
protected javax.sound.sampled.SourceDataLine m_line
protected javax.sound.sampled.FloatControl m_gainControl
protected javax.sound.sampled.FloatControl m_panControl
protected java.lang.String m_mixerName
public static final int UNKNOWN
public static final int PLAYING
public static final int PAUSED
public static final int STOPPED
public static final int OPENED
public static final int SEEKING
Constructor Detail |
---|
public BasicPlayer()
Method Detail |
---|
protected void reset()
public void addBasicPlayerListener(BasicPlayerListener bpl)
bpl
- public java.util.Collection getListeners()
public void removeBasicPlayerListener(BasicPlayerListener bpl)
bpl
- public void setLineBufferSize(int size)
size
- -1 means maximum buffer size available.public int getLineBufferSize()
public int getLineCurrentBufferSize()
public void setSleepTime(long time)
time
- in milliseconds.public long getSleepTime()
public int getStatus()
public void open(java.io.File file) throws BasicPlayerException
open
in interface BasicController
BasicPlayerException
public void open(java.net.URL url) throws BasicPlayerException
open
in interface BasicController
BasicPlayerException
public void open(java.io.InputStream inputStream) throws BasicPlayerException
open
in interface BasicController
BasicPlayerException
protected void initAudioInputStream() throws BasicPlayerException
BasicPlayerException
protected void initAudioInputStream(java.io.File file) throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
protected void initAudioInputStream(java.net.URL url) throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
protected void initAudioInputStream(java.io.InputStream inputStream) throws javax.sound.sampled.UnsupportedAudioFileException, java.io.IOException
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
protected void initLine() throws javax.sound.sampled.LineUnavailableException
javax.sound.sampled.LineUnavailableException
protected void createLine() throws javax.sound.sampled.LineUnavailableException
javax.sound.sampled.LineUnavailableException
protected void openLine() throws javax.sound.sampled.LineUnavailableException
javax.sound.sampled.LineUnavailableException
protected void stopPlayback()
protected void pausePlayback()
protected void resumePlayback()
protected void startPlayback() throws BasicPlayerException
BasicPlayerException
public void run()
run
in interface java.lang.Runnable
protected long skipBytes(long bytes) throws BasicPlayerException
bytes
-
BasicPlayerException
protected void notifyEvent(int code, int position, double value, java.lang.Object description)
code
- event code.position
- in the stream when the event occurs.protected int getEncodedStreamPosition()
protected void closeStream()
public boolean hasGainControl()
public float getGainValue()
public float getMaximumGain()
public float getMinimumGain()
public boolean hasPanControl()
public float getPrecision()
public float getPan()
protected java.util.Map deepCopy(java.util.Map src)
src
-
public long seek(long bytes) throws BasicPlayerException
BasicController
seek
in interface BasicController
BasicPlayerException
BasicController.seek(long)
public void play() throws BasicPlayerException
BasicController
play
in interface BasicController
BasicPlayerException
BasicController.play()
public void stop() throws BasicPlayerException
BasicController
stop
in interface BasicController
BasicPlayerException
BasicController.stop()
public void pause() throws BasicPlayerException
BasicController
pause
in interface BasicController
BasicPlayerException
BasicController.pause()
public void resume() throws BasicPlayerException
BasicController
resume
in interface BasicController
BasicPlayerException
BasicController.resume()
public void setPan(double fPan) throws BasicPlayerException
setPan
in interface BasicController
fPan
- value from -1.0 to +1.0
BasicPlayerException
public void setGain(double fGain) throws BasicPlayerException
setGain
in interface BasicController
fGain
- value from 0.0 to 1.0
BasicPlayerException
public java.util.List getMixers()
public javax.sound.sampled.Mixer getMixer(java.lang.String name)
public java.lang.String getMixerName()
public void setMixerName(java.lang.String name)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |