javazoom.jlGui
Class BasicPlayer

java.lang.Object
  |
  +--javazoom.jlGui.BasicPlayer
All Implemented Interfaces:
java.lang.Runnable

public class BasicPlayer
extends java.lang.Object
implements java.lang.Runnable

BasicPlayer implements basics features of a player. The playback is done with a thread. BasicPlayer is the result of jlGui 0.5 from JavaZOOM and BaseAudioStream from Matthias Pfisterer JavaSound examples.

Author:
E.B from JavaZOOM Homepage : http://www.javazoom.net

Field Summary
static int PAUSED
          These variables are used to distinguish stopped, paused, playing states.
static int PLAYING
           
static int READY
           
static int STOPPED
           
 
Constructor Summary
BasicPlayer()
          Constructs a Basic Player.
BasicPlayer(BasicPlayerListener bpl)
          Constructs a Basic Player with a BasicPlayerListener.
 
Method Summary
 javax.sound.sampled.AudioFileFormat getAudioFileFormat()
          Returns source AudioFileFormat.
 javax.sound.sampled.AudioFormat getAudioFormat()
          Returns source AudioFormat.
 int getBitRate()
          Returns bit rate.
 float getGain()
          Returns Gain value.
 float getMaximum()
          Gets max Gain value.
 float getMinimum()
          Gets min Gain value.
 float getPan()
          Returns Pan value.
 float getPrecision()
          Returns Pan precision.
 int getStatus()
          Returns BasicPlayer status.
 double getTotalLengthInSeconds()
          Returns total length in seconds.
 boolean hasGainControl()
          Returns true if Gain control is supported.
 boolean hasPanControl()
          Returns true if Pan control is supported.
protected  void initLine()
          Inits Audio ressources from AudioSystem.
DateSource must be present.
protected  java.io.InputStream openInput(java.io.File file)
          Gets an InputStream from File.
 void pausePlayback()
          Pauses the playback.
Player Status = PAUSED.
 void resumePlayback()
          Resumes the playback.
Player Status = PLAYING.
 void run()
          Main loop.
 void setDataSource(java.io.File file)
          Sets the data source as a file.
 void setDataSource(java.net.URL url)
          Sets the data source as an url.
 void setGain(double fGain)
          Sets Gain value.
 void setPan(float fPan)
          Sets Pan value.
 void setSeek(double seek)
          Sets Seek value.
 java.lang.String startPlayback()
          Starts playback.
 void stopPlayback()
          Stops the playback.
Player Status = STOPPED.
Thread should free Audio ressources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAUSED

public static final int PAUSED
These variables are used to distinguish stopped, paused, playing states. We need them to control Thread.

PLAYING

public static final int PLAYING

STOPPED

public static final int STOPPED

READY

public static final int READY
Constructor Detail

BasicPlayer

public BasicPlayer()
Constructs a Basic Player.

BasicPlayer

public BasicPlayer(BasicPlayerListener bpl)
Constructs a Basic Player with a BasicPlayerListener.
Method Detail

getStatus

public int getStatus()
Returns BasicPlayer status.

setDataSource

public void setDataSource(java.io.File file)
                   throws javax.sound.sampled.UnsupportedAudioFileException,
                          javax.sound.sampled.LineUnavailableException,
                          java.io.IOException
Sets the data source as a file.

setDataSource

public void setDataSource(java.net.URL url)
                   throws javax.sound.sampled.UnsupportedAudioFileException,
                          javax.sound.sampled.LineUnavailableException,
                          java.io.IOException
Sets the data source as an url.

initLine

protected void initLine()
                 throws javax.sound.sampled.LineUnavailableException
Inits Audio ressources from AudioSystem.
DateSource must be present.

stopPlayback

public void stopPlayback()
Stops the playback.
Player Status = STOPPED.
Thread should free Audio ressources.

pausePlayback

public void pausePlayback()
Pauses the playback.
Player Status = PAUSED.

resumePlayback

public void resumePlayback()
Resumes the playback.
Player Status = PLAYING.

startPlayback

public java.lang.String startPlayback()
Starts playback.

run

public void run()
Main loop. Player Status == STOPPED => End of Thread + Freeing Audio Ressources.
Player Status == PLAYING => Audio stream data sent to Audio line.
Player Status == PAUSED => Waiting for another status.
Specified by:
run in interface java.lang.Runnable

hasGainControl

public boolean hasGainControl()
Returns true if Gain control is supported.

setGain

public void setGain(double fGain)
Sets Gain value. Linear scale 0.0 <--> 1.0 Threshold Coef. : 1/2 to avoid saturation.

getGain

public float getGain()
Returns Gain value.

getMaximum

public float getMaximum()
Gets max Gain value.

getMinimum

public float getMinimum()
Gets min Gain value.

hasPanControl

public boolean hasPanControl()
Returns true if Pan control is supported.

getPrecision

public float getPrecision()
Returns Pan precision.

getPan

public float getPan()
Returns Pan value.

setPan

public void setPan(float fPan)
Sets Pan value. Linear scale : -1.0 <--> +1.0

setSeek

public void setSeek(double seek)
             throws java.io.IOException
Sets Seek value. Linear scale : 0.0 <--> +1.0

getAudioFormat

public javax.sound.sampled.AudioFormat getAudioFormat()
Returns source AudioFormat.

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat()
Returns source AudioFileFormat.

getTotalLengthInSeconds

public double getTotalLengthInSeconds()
Returns total length in seconds.

getBitRate

public int getBitRate()
Returns bit rate.

openInput

protected java.io.InputStream openInput(java.io.File file)
                                 throws java.io.IOException
Gets an InputStream from File.


JavaZOOM 1999-2002