danger.player
Class MusicPlayer

java.lang.Object
  extended by danger.player.MusicPlayer


public class MusicPlayer
extends Object

Public information about the state of the music player.


Method Summary
static AudioTrack getCurrentTrack()
          Gets the track the media player is currently playing, or played most recently.
static String getPlayerName()
          Return the human-readable name of the music player application.
static int getVolume()
          Get the volume of the currently playing music.
static boolean isInstalled()
          Is the music player installed.
static boolean isMiniPlayerVisible()
           
static boolean isPaused()
          Whether or not the media player is currently paused.
static boolean isPlaying()
          Whether or not the media player is currently playing a track.
static boolean isStopped()
          Whether or not the media player is currently stopped.
static boolean isVisible()
          Is the music player visible to the user.
static void moveToNextTrack()
          Start playing the next track in the play queue.
static void moveToPreviousTrack()
          Start playing the previous track in the play queue.
static void pause()
          Pause the mediaplayer.
static void play()
          Start playing the mediaplayer.
static void registerMediaPlayerStateListener(Listener listener)
          Registers a listener for media player events, sending out the current state via events.
static void restartOrMoveToPreviousTrack()
          Start playing previous track or restart the current track based on logic in the mediaplayer.
static void restartTrack()
          Start playing the current track from the beginning.
static void stop()
          Stop the mediaplayer.
static void togglePlayPause()
          If the mediaplayer is playing, then this will pause it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerMediaPlayerStateListener

public static void registerMediaPlayerStateListener(Listener listener)
Registers a listener for media player events, sending out the current state via events.


isMiniPlayerVisible

public static boolean isMiniPlayerVisible()

isInstalled

public static boolean isInstalled()
Is the music player installed. Information from other methods in this class is only valid if this method returns true.

Returns:
true if the device has a music player installed.

isVisible

public static boolean isVisible()
Is the music player visible to the user. This method returns true if any form of the music player is visible to the user, regardless of what state the player is in. It currently returns true if you are in the music player application or have the mini player displayed.

Returns:
true if the music player is visible.

getPlayerName

public static String getPlayerName()
Return the human-readable name of the music player application.

Returns:
String containing the name of the music player or null if no player is installed.

isPlaying

public static boolean isPlaying()
Whether or not the media player is currently playing a track.


isPaused

public static boolean isPaused()
Whether or not the media player is currently paused.


isStopped

public static boolean isStopped()
Whether or not the media player is currently stopped.


getVolume

public static int getVolume()
Get the volume of the currently playing music.

Returns:
Volume (0..100) if music is playing or -1.

getCurrentTrack

public static AudioTrack getCurrentTrack()
Gets the track the media player is currently playing, or played most recently.


play

public static void play()
Start playing the mediaplayer.

Since:
4.5

pause

public static void pause()
Pause the mediaplayer.

Since:
4.5

stop

public static void stop()
Stop the mediaplayer.

Since:
4.5

togglePlayPause

public static void togglePlayPause()
If the mediaplayer is playing, then this will pause it. If it is not playing, then this will start it.

Since:
4.5

moveToNextTrack

public static void moveToNextTrack()
Start playing the next track in the play queue.

Since:
4.5

moveToPreviousTrack

public static void moveToPreviousTrack()
Start playing the previous track in the play queue.

Since:
4.5

restartTrack

public static void restartTrack()
Start playing the current track from the beginning.

Since:
4.5

restartOrMoveToPreviousTrack

public static void restartOrMoveToPreviousTrack()
Start playing previous track or restart the current track based on logic in the mediaplayer. Typically, the previous track would start if less than a second or two of the current track had elapsed.

Since:
4.5