A JavaScript API for controlling the player should help web designers/developers create HTML/JavaScript/CSS based player controls. The same JavaScript API could potentially be used for our future work on the HTML5 fallback and should allow site-owners to provide exactly the same controls for both Flash-based video players and the HTML5 fallback players.
We will focus on the control API, since the SWFObject library is enough for most JavaScript configuration scenarios.
As Jason, The Web developer, working a lot with Dreamweaver I know that I can use SwfObject to embed the player and configure it but I also want to be able to control it from JavaScript : play/pause, seek, etc.
We expose the MediaPlayer public API as JavaScript API.
That means that all the MediaPlayer public methods and properties are accessible from JavaScript. The only difference is that we need to use getter/setters instead of accessing the properties directly - bufferTime is exposed as getBufferTime() and setBufferTime(value).
At the same time we expose a method that can be used for handling MediaPlayer events.
You simply need to register for a specific event using the API that is already familiar to any OSMF or AS3 developer:
addEventListener(eventName, callback)
We also provide an utility function, named addEventListeners, which takes an object containing key-value pairs. This method should help in speeding up the configuration process.
Once the strobe StrobeMediaPlayback is loaded it will call onJavaScriptBridgeCreated javascript function. You need to use this callback function for starting the interaction with the player.
. - + * / \
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html
The Hello World Sample (hello-world-javascript.html) will be updating the current video time and the the video duration in a HTML div.
At the same time it allows you to pause/resume the video.
Basic workflow:
1. Embed the player
2. Create a onJavaScriptBridgeCreated function
3. Retrieve a reference to the video player
4. Register event listeners
4. Check the state of the player and control the player in your event handlers.
This demo (jsdemo.html) demostrates most of the features of the JavaScript API, except metadata and the plugin interactions which will be providing as deliverables of a future feature.
Displaying HTML overlays over the video is a performance issue.
Some JavaScript API users might be tempted into turning the wmode into "opaque" or "transparent" so that they can display HTML content over the StrobeMediaPlayback video content. This would be wrong from a perfromance perspective because flash 10.1 won't be able to use hardware acceleration for rendering the video. Flash Player 10.1 hardware rendering is automatically enabled on supported devices, and it's not necessary to add the wmode=gpu embed parameter to enable it. However, when working with Flash Player 10.1, the wmode=opaque or wmode=transparent embed parameters will disable hardware rendering, causing the software to render the graphics.
ExternalInterface reference: http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html
ExternalInterface performance overhead: http://engin.bzzzt.biz/2010/04/15/externalinterface-performance-on-different-browsers/
Flash Player 10.1 hardware acceleration for video and graphics: http://www.adobe.com/devnet/flashplayer/articles/fplayer10.1_hardware_acceleration.html
Building a custom HTML5 video player with CSS3 and jQuery: http://dev.opera.com/articles/view/custom-html5-video-player-with-css3-and-jquery/