player
Class AudioPlayer

java.lang.Object
  extended by player.AudioPlayer
All Implemented Interfaces:
java.lang.Runnable

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

A simple Playerthread to play audiofiles. The player can play a single MapItem or a list of items (see MapItemList). Depending on the configuration the player streams audiofiles from a server or plays them from the device. The player can also act as a remote control, meaning instead of playling a piece of music, the player will trigger another device to play the song.

Author:
Peter Hlavac

Constructor Summary
AudioPlayer(PropertyManager pm)
          Creates the AudioPlayer Thread
 
Method Summary
 void backward()
          Skips to the previous track
 void forward()
          Skips to the next track
 int getCurrentItemIndex()
          Gets the position of the current item in the playlist
 java.lang.String getCurrentSong()
          Returns the name (song title) of the current song
 java.lang.String getCurrentTime()
          Gets the current time in [mm:ss]
 int getPlayListLength()
          Returns the number of items in a playlist
 java.lang.String getRemoteServer()
           
 void initPlayList(MapItem mapItem)
          Inits the playlist with a single item
 void initPlayList(MapItemList playList)
          Inits the playlist with a list of items
 boolean isPlaying()
          Returns the player status.
 void moveDown(int index)
          Moves a song down in the playlist
 void moveUp(int index)
          Moves a song up in the playlist
 void run()
          The thread's "run"-method creates a player and plays the item with "currentItemIndex" from the playlist and continues as long as there are more items in the playlist left.
 void setBRemote(boolean bRemote)
          Turns the remote mode on or off
 void start(boolean bRemote, int startFrom)
          Starts the Thread to play item(s)
 void stopPlayer()
          Stops the player
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioPlayer

public AudioPlayer(PropertyManager pm)
Creates the AudioPlayer Thread

Parameters:
pm - Properties
Method Detail

getRemoteServer

public java.lang.String getRemoteServer()

initPlayList

public void initPlayList(MapItemList playList)
Inits the playlist with a list of items

Parameters:
playList - a list of items to be played

initPlayList

public void initPlayList(MapItem mapItem)
Inits the playlist with a single item

Parameters:
mapItem - the Item to be played

start

public void start(boolean bRemote,
                  int startFrom)
Starts the Thread to play item(s)

Parameters:
bRemote - indicates if songs are played from the mobile or on a different device
startFrom - the index where to start in the playlist

stopPlayer

public void stopPlayer()
Stops the player


forward

public void forward()
Skips to the next track


backward

public void backward()
Skips to the previous track


moveDown

public void moveDown(int index)
Moves a song down in the playlist

Parameters:
index - the index of the item in the playlist

moveUp

public void moveUp(int index)
Moves a song up in the playlist

Parameters:
index - the index of the item in the playlist

run

public void run()
The thread's "run"-method creates a player and plays the item with "currentItemIndex" from the playlist and continues as long as there are more items in the playlist left.

Specified by:
run in interface java.lang.Runnable

setBRemote

public void setBRemote(boolean bRemote)
Turns the remote mode on or off

Parameters:
bRemote - TRUE for remote mode, FALSE otherwise

isPlaying

public boolean isPlaying()
Returns the player status. TRUE for playing, FALSE otherwise

Returns:
player status

getCurrentSong

public java.lang.String getCurrentSong()
Returns the name (song title) of the current song

Returns:
name

getCurrentTime

public java.lang.String getCurrentTime()
Gets the current time in [mm:ss]

Returns:
the current time of the played song in [mm:ss]

getCurrentItemIndex

public int getCurrentItemIndex()
Gets the position of the current item in the playlist

Returns:
the index of the current item

getPlayListLength

public int getPlayListLength()
Returns the number of items in a playlist

Returns:
the size of the playlist