com.googlecode.android_scripting.facade
Class MediaPlayerFacade

java.lang.Object
  extended by com.googlecode.android_scripting.jsonrpc.RpcReceiver
      extended by com.googlecode.android_scripting.facade.MediaPlayerFacade

public class MediaPlayerFacade
extends RpcReceiver

This facade exposes basic mediaPlayer functionality.

Usage Notes:
mediaPlayerFacade maintains a list of media streams, identified by a user supplied tag. If the tag is null or blank, this tag defaults to "default"
Basic operation is: mediaPlayOpen("file:///sdcard/MP3/sample.mp3","mytag",true)
This will look for a media file at /sdcard/MP3/sample.mp3. Other urls should work. If the file exists and is playable, this will return a true otherwise it will return a false.
If play=true, then the media file will play immediately, otherwise it will wait for a mediaPlayerStart command.
When done with the resource, use mediaPlayClose
You can get information about the loaded media with mediaPlayInfo This returns a map with the following elements:


You can use mediaPlayList to get a list of the loaded tags.
mediaIsPlaying will return true if the media is playing.
Events:
A playing media will throw a "media" event on completion. NB: In remote mode, a media file will continue playing after the script has finished unless an explicit mediaPlayClose event is called.

Author:
Robbie Matthews (rjmatthews62@gmail.com)

Constructor Summary
MediaPlayerFacade(FacadeManager manager)
           
 
Method Summary
 boolean mediaIsPlaying(java.lang.String tag)
           
 boolean mediaPlay(java.lang.String url, java.lang.String tag, java.lang.Boolean play)
           
 boolean mediaPlayClose(java.lang.String tag)
           
 java.util.Map<java.lang.String,java.lang.Object> mediaPlayInfo(java.lang.String tag)
           
 java.util.Set<java.lang.String> mediaPlayList()
           
 boolean mediaPlayPause(java.lang.String tag)
           
 int mediaPlaySeek(java.lang.Integer msec, java.lang.String tag)
           
 boolean mediaPlaySetLooping(java.lang.Boolean enabled, java.lang.String tag)
           
 boolean mediaPlayStart(java.lang.String tag)
           
 void onCompletion(MediaPlayer player)
           
 void shutdown()
          Invoked when the receiver is shut down.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediaPlayerFacade

public MediaPlayerFacade(FacadeManager manager)
Method Detail

mediaPlay

@Rpc(description="Open a media file",
     returns="true if play successful")
public boolean mediaPlay(@RpcParameter(name="url",description="url of media resource")
                                               java.lang.String url,
                                               @RpcParameter(name="tag",description="string identifying resource")@RpcDefault(value="default")
                                               java.lang.String tag,
                                               @RpcParameter(name="play",description="start playing immediately")@RpcDefault(value="true")
                                               java.lang.Boolean play)

mediaPlayPause

@Rpc(description="pause playing media file",
     returns="true if successful")
public boolean mediaPlayPause(@RpcParameter(name="tag",description="string identifying resource")@RpcDefault(value="default")
                                                    java.lang.String tag)

mediaPlayStart

@Rpc(description="start playing media file",
     returns="true if successful")
public boolean mediaPlayStart(@RpcParameter(name="tag",description="string identifying resource")@RpcDefault(value="default")
                                                    java.lang.String tag)

mediaPlayClose

@Rpc(description="Close media file",
     returns="true if successful")
public boolean mediaPlayClose(@RpcParameter(name="tag",description="string identifying resource")@RpcDefault(value="default")
                                                    java.lang.String tag)

mediaIsPlaying

@Rpc(description="Checks if media file is playing.",
     returns="true if playing")
public boolean mediaIsPlaying(@RpcParameter(name="tag",description="string identifying resource")@RpcDefault(value="default")
                                                    java.lang.String tag)

mediaPlayInfo

@Rpc(description="Information on current media",
     returns="Media Information")
public java.util.Map<java.lang.String,java.lang.Object> mediaPlayInfo(@RpcParameter(name="tag",description="string identifying resource")@RpcDefault(value="default")
                                                                                            java.lang.String tag)

mediaPlayList

@Rpc(description="Lists currently loaded media",
     returns="List of Media Tags")
public java.util.Set<java.lang.String> mediaPlayList()

mediaPlaySetLooping

@Rpc(description="Set Looping",
     returns="True if successful")
public boolean mediaPlaySetLooping(@RpcParameter(name="enabled")@RpcDefault(value="true")
                                                         java.lang.Boolean enabled,
                                                         @RpcParameter(name="tag",description="string identifying resource")@RpcDefault(value="default")
                                                         java.lang.String tag)

mediaPlaySeek

@Rpc(description="Seek To Position",
     returns="New Position (in ms)")
public int mediaPlaySeek(@RpcParameter(name="msec",description="Position in millseconds")
                                               java.lang.Integer msec,
                                               @RpcParameter(name="tag",description="string identifying resource")@RpcDefault(value="default")
                                               java.lang.String tag)

shutdown

public void shutdown()
Description copied from class: RpcReceiver
Invoked when the receiver is shut down.

Specified by:
shutdown in class RpcReceiver

onCompletion

public void onCompletion(MediaPlayer player)