javazoom.jl.player

Class PlayerApplet

Implemented Interfaces:
Runnable

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 String
AUDIO_PARAMETER

Method Summary

protected Thread
createPlayerThread()
Creates a new thread used to run the audio player.
void
destroy()
protected AudioDevice
getAudioDevice()
Retrieves the AudioDevice instance that will be used to sound the audio data.
protected String
getAudioFileName()
protected InputStream
getAudioStream()
Retrieves the InputStream that provides the MPEG audio stream data.
protected URL
getAudioURL()
String
getFileName()
void
init()
Initializes this applet.
protected void
play(InputStream in, AudioDevice dev)
Decompresses audio data from an InputStream and plays it back through an AudioDevice.
void
run()
The run method for the audio player thread.
void
setFileName(String name)
Sets the URL of the audio stream to play.
void
start()
Starts this applet.
void
stop()
Stops this applet.
protected void
stopPlayer()
Stops the audio player.

Field Details

AUDIO_PARAMETER

public static final String AUDIO_PARAMETER

Method Details

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()
            throws JavaLayerException
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)
            throws JavaLayerException
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()
            throws JavaLayerException
Stops the audio player. If the player is already stopped this method is a no-op.

JavaZOOM 1999-2005