com.googlecode.android_scripting.facade
Class MediaPlayerFacade
java.lang.Object
com.googlecode.android_scripting.jsonrpc.RpcReceiver
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:
- "tag" - user supplied tag identifying this mediaPlayer.
- "loaded" - true if loaded, false if not. If false, no other elements are returned.
- "duration" - length of the media in milliseconds.
- "position" - current position of playback in milliseconds. Controlled by
mediaPlaySeek
- "isplaying" - shows whether media is playing. Controlled by
mediaPlayPause and mediaPlayStart
- "url" - the url used to open this media.
- "looping" - whether media will loop. Controlled by
mediaPlaySetLooping
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)
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MediaPlayerFacade
public MediaPlayerFacade(FacadeManager manager)
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)