ch.aplu.gidlet
Class AudioPlayer

java.lang.Object
  extended by ch.aplu.gidlet.AudioPlayer
All Implemented Interfaces:
java.lang.Runnable, javax.microedition.media.PlayerListener

public class AudioPlayer
extends java.lang.Object
implements javax.microedition.media.PlayerListener, java.lang.Runnable

Class that wraps the J2ME MMAPI class javax.microedition.media.Player in order to start/resume, pause and stop playing audio files in a separate thread.


Field Summary
 
Fields inherited from interface javax.microedition.media.PlayerListener
BUFFERING_STARTED, BUFFERING_STOPPED, CLOSED, DEVICE_AVAILABLE, DEVICE_UNAVAILABLE, DURATION_UPDATED, END_OF_MEDIA, ERROR, RECORD_ERROR, RECORD_STARTED, RECORD_STOPPED, SIZE_CHANGED, STARTED, STOPPED, STOPPED_AT_TIME, VOLUME_CHANGED
 
Constructor Summary
AudioPlayer(java.io.InputStream is, java.lang.String mimeType)
          Creates a Player in a separate thread from given input stream and mime type.
AudioPlayer(java.lang.String uri)
          Creates a Player in a separate thread from given HTTP uri.
AudioPlayer(java.lang.String audioFile, java.lang.String mimeType)
          Creates a Player in a separate thread from given resource file and mime type.
 
Method Summary
 void close()
          Releases all connections and resources.
 javax.microedition.media.Player getPlayer()
          Gets a reference to the Player instance.
 void pause()
          Pauses playing. start() will resume at current media time.
 void playerUpdate(javax.microedition.media.Player player, java.lang.String event, java.lang.Object eventData)
          For internal use only.
 void run()
          For internal use only.
 void start()
          Starts or resumes playing at current media time.
 void stop()
          Stops playing and set media time to zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioPlayer

public AudioPlayer(java.lang.String audioFile,
                   java.lang.String mimeType)
Creates a Player in a separate thread from given resource file and mime type. Blocks until Player's realize() and prefetch() are done. Media time is zero.


AudioPlayer

public AudioPlayer(java.io.InputStream is,
                   java.lang.String mimeType)
Creates a Player in a separate thread from given input stream and mime type. Blocks until Player's realize() and prefetch() are done. Media time is zero.


AudioPlayer

public AudioPlayer(java.lang.String uri)
Creates a Player in a separate thread from given HTTP uri. Blocks until Player's realize() and prefetch() are done. Media time is zero.

Method Detail

getPlayer

public javax.microedition.media.Player getPlayer()
Gets a reference to the Player instance.


start

public void start()
Starts or resumes playing at current media time.


pause

public void pause()
Pauses playing. start() will resume at current media time.


stop

public void stop()
Stops playing and set media time to zero.


close

public void close()
Releases all connections and resources. No methods of this instance should be called any more. Block until thread is dead.


run

public void run()
For internal use only.

Specified by:
run in interface java.lang.Runnable

playerUpdate

public void playerUpdate(javax.microedition.media.Player player,
                         java.lang.String event,
                         java.lang.Object eventData)
For internal use only.

Specified by:
playerUpdate in interface javax.microedition.media.PlayerListener