
Mobile Widgets
MediaSensor and MediaControl
Introduction
This part presents how to control audio and video playing.
MediaSensor and
MediaControl nodes can be used
with audio and video nodes (MovieTexture and AudioClip).
Important:
Before, read basic audio/video tutorial.
Audio and video support
Use a MeMo Player with audio and video support.
See basic audio/video tutorial for more informations.
Display playing progression
MediaSensor node return
information about playing progression.
MediaSensor interface:
See MediaSensor documentation for more informations about fields.
In first time we create a text node to display status and progression.
Note:
in a real widget, we can use a progress bar. See prototype tutorial.
We add a MovieTexture node to display video.
Note:
Add video nodes before previous text nodes.
And we add the [MediaSensor].
MediaSensor and
MovieTexture have the same URL.
We add a MovieTexture node to display video.
Note:
Add video nodes before previous text nodes.
And we add the MediaSensor.
MediaSensor and
MovieTexture have the same URL.
We create JavaScript node to display MediaSensor event.
We listen two events:
- mediaCurrentTime event (send during video playing): We display current position into media file (in percent).
- status event (send media node state): We display current media state (stop, play, ...).
updateMediaProgression() function convert current time into percent value and display it.
updateMediaStatus() function display current media status.
Finally, route MediaSensor events to script functions:
Complete source code for this example:
Control audio and video playing
MediaControl node control media playing.
MediaControl interface:
See MediaControl documentation for more informations about fields.