javazoom.jl.player

Class PlayerApplet

public class PlayerApplet extends Applet implements Runnable

A simple applet that plays an MPEG audio file. The URL (relative to the document base) is passed as the "audioURL" parameter.

Since: 0.0.8

Field Summary
static StringAUDIO_PARAMETER
Method Summary
protected ThreadcreatePlayerThread()
Creates a new thread used to run the audio player.
voiddestroy()
protected AudioDevicegetAudioDevice()
Retrieves the AudioDevice instance that will be used to sound the audio data.
protected StringgetAudioFileName()
protected InputStreamgetAudioStream()
Retrieves the InputStream that provides the MPEG audio stream data.
protected URLgetAudioURL()
StringgetFileName()
voidinit()
Initializes this applet.
protected voidplay(InputStream in, AudioDevice dev)
Decompresses audio data from an InputStream and plays it back through an AudioDevice.
voidrun()
The run method for the audio player thread.
voidsetFileName(String name)
Sets the URL of the audio stream to play.
voidstart()
Starts this applet.
voidstop()
Stops this applet.
protected voidstopPlayer()
Stops the audio player.

Field Detail

AUDIO_PARAMETER

public static final String AUDIO_PARAMETER

Method Detail

createPlayerThread

protected Thread createPlayerThread()
Creates a new thread used to run the audio player.

Returns: A new Thread that, once started, runs the audio player.

destroy

public void destroy()

getAudioDevice

protected AudioDevice getAudioDevice()
Retrieves the AudioDevice instance that will be used to sound the audio data.

Returns: an audio device instance that will be used to sound the audio stream.

getAudioFileName

protected String getAudioFileName()

getAudioStream

protected InputStream getAudioStream()
Retrieves the InputStream that provides the MPEG audio stream data.

Returns: an InputStream from which the MPEG audio data is read, or null if an error occurs.

getAudioURL

protected URL getAudioURL()

getFileName

public String getFileName()

init

public void init()
Initializes this applet.

play

protected void play(InputStream in, AudioDevice dev)
Decompresses audio data from an InputStream and plays it back through an AudioDevice. The playback is run on a newly created thread.

Parameters: in The InputStream that provides the MPEG audio data. dev The AudioDevice to use to sound the decompressed data.

Throws: JavaLayerException if there was a problem decoding or playing the audio data.

run

public void run()
The run method for the audio player thread. Simply calls play() on the player to play the entire stream.

setFileName

public void setFileName(String name)
Sets the URL of the audio stream to play.

start

public void start()
Starts this applet. An input stream and audio device are created and passed to the play() method.

stop

public void stop()
Stops this applet. If audio is currently playing, it is stopped.

stopPlayer

protected void stopPlayer()
Stops the audio player. If the player is already stopped this method is a no-op.
JavaZOOM 1999-2005