-
Notifications
You must be signed in to change notification settings - Fork 17
SL4A MediaPlayerFacade
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.