comirva.audio
Class AudioPlaylistPlayer

java.lang.Object
  extended by java.lang.Thread
      extended by comirva.audio.AudioPlaylistPlayer
All Implemented Interfaces:
Runnable

public class AudioPlaylistPlayer
extends Thread

This class implements a playlist for audio files.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AudioPlaylistPlayer()
          Creates a new empty playlist.
AudioPlaylistPlayer(Vector<File> audioFiles)
          Creates a new playlist that contains the files given as arguments.
 
Method Summary
 void addTrack(File audioFile)
          Adds a file to the playlist.
 void continuePlaying()
          Continues the audio output if it is paused.
 File getTrack(int position)
          Returns the audio file at the given position in the playlist.
 boolean isPaused()
          Returns whether the audio output is paused.
 void pausePlaying()
          Pauses the audio output.
 void playNext()
          Plays the next track of the playlist.
 void playPrevious()
          Plays the previous track of the playlist.
 void removeTrack(int position)
          Removes the audio file at the given position in the playlist.
 void run()
          This method is called when the thread is started.
 void stopPlaying()
          Stops the audio output.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AudioPlaylistPlayer

public AudioPlaylistPlayer()
Creates a new empty playlist.


AudioPlaylistPlayer

public AudioPlaylistPlayer(Vector<File> audioFiles)
Creates a new playlist that contains the files given as arguments.

Parameters:
audioFiles - a Vector containing the files to be inserted into the playlist as File.
Method Detail

run

public void run()
This method is called when the thread is started. It starts to play from the beginning of the playlist.

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Runnable.run()

addTrack

public void addTrack(File audioFile)
Adds a file to the playlist.

Parameters:
audioFile - the File to be added

removeTrack

public void removeTrack(int position)
Removes the audio file at the given position in the playlist.

Parameters:
position - the position of the audio file in the playlist that should be removed (starts with 0)

getTrack

public File getTrack(int position)
Returns the audio file at the given position in the playlist.

Parameters:
position - the position of the audio file in the playlist that should be returned (starts with 0)
Returns:
the File at the requested position in the playlist

playNext

public void playNext()
Plays the next track of the playlist. If the currently played track is the last one, the first track is played instead.


playPrevious

public void playPrevious()
Plays the previous track of the playlist. If the currently played track is the first one, the last track is played instead.


pausePlaying

public void pausePlaying()
Pauses the audio output.


continuePlaying

public void continuePlaying()
Continues the audio output if it is paused.


isPaused

public boolean isPaused()
Returns whether the audio output is paused.

Returns:
a boolean indicating if the audio output is paused

stopPlaying

public void stopPlaying()
Stops the audio output.