4.4: Interfacing with your video player from JavaScript
The video player from 23 Video can be controlled from JavaScript -- that is, the video can be played and paused, and you can get information about the current playing video and the state of the video player.
Calling the video player from JavaScript
The JavaScript interface uses Flash's built-in ExternalInterface, and calling the exposed JavaScript simply requires a reference to the DOM object containing the video player. This can be done using a simple function responsible for handling different embed models in different browsers:
function getFlexApp(appName) {
if (navigator.appName.indexOf ("Microsoft") !=-1) {
return window[appName];
} else {
return document[appName];
}
}
We'll embed the video player with the ID/NAME videoplayer:
<object id="videoplayer" ...><embed name="videoplayer" ... /></object ...>
When you're embedding using straight HTML there's some trickery in making Flash interfacing work across browsers. The trick is to use both <object id="videoplayer" ...> and <embed name="videoplayer" ...>. Also, make sure the classid property is set while leaving out type and data on the <object> tag.
The standard embed code from 23 Video is built correctly -- but you'll need to add id and name.
This makes the video player calling very easy with a few lines of code:
var app = getFlexApp('videoplayer');
app.playVideo();
alert(app.getPlayState());
Whenever possible, it is suggested you embed video from 23 Video via JavaScript and SWFObject. The embed codes can be found within the administration interface and will also work using the exact same code as above:
<script
src="http://yourvideodomain.com/resources/um/script/swfobject/swfobject.js"></script>
<div id="videoplayer" class="embedded-video">
<div class="no-flash">You have an old version of Adobe's Flash Player ...</div>
</div>
<script>
swfobject.embedSWF("http://yourvideodomain.com/v.swf", "videoplayer", "595",
"340", "9.0.0", "/resources/um/script/swfobject/expressInstall.swf",
{"photo_id": "12345"}, {allowscriptaccess:'always', allowfullscreen:'true'},
{id:'videoplayer', name:'videoplayer'});
</script>
Important note: The interface is only available after the DOM has been loaded in the browser. This means that you won't be able to use the code above during page load; it'll only work after the entire web page has been prepared.
See demos of both approaches:
Available methods
| Method | Description |
|---|---|
| .playVideo() | Start playback. |
| .pauseVideo() | Pause playback. |
| .getPlayState() | Returns information about the current play state of the player. Possible values are buffering, playing, and paused. |
| .getPlayheadTime() | Returns number of seconds played. |
| .setPlayheadTime(timeInSecs) | Skips to a specific point in the video being played. |
| .getTotalTime() | Returns total number of seconds in the currently playing video clip. |
| .getCurrentPhotoID() | Return the ID of the currently playing video. |
| .getJSONSource() | Returns the full URL of the JSON source used to populate the video player. This is useful if you need more information about the video being played. |
| .echo(echoValue) | Returns the value of the argument. For example player.echo('23') will return 23. This is useful for testing. |
| .unloadVideoPlayer() | Unloads the player. If possible, call this from the window.beforeunload event; it will stop playback and make optimize the user experience. |
Adding new JavaScript methods to the player
The set of exposed functions or methods is fairly limited, but more can easily be added. Simply create your own custom player and add ExternalInterface callbacks to the init() method on VideoPlayer.mxml.





Comments
Own more than 100 years history, Mulberry Bag is most people’s favorite for it’s real leather material and exterior originality. Fashion mulberry design with more pockets, buckles and more beautiful with practical with rivets, make the mulberry popularity worldwide. Specialized in the leather, forged by masterly craft, Mulberry Factory Shop sale Mulberry Handbags, Mulberry Alexa,Bags, Mulberry Bayswater Bags, Mulberry Clutch Bags, Mulberry Purse, Mulberry Hobo Bags,etc. Top quality Mulberry sale in the Mulberry UK Shop, combined with the practical, creating original and leather tactility, Mulberry Handbags UK try to be unique creative design. Full collection of Mulberry Bags with different leather materials and sizes in the Mulberry Bag online shop, mulberry calf leather bags, mulberry ostrich leather bags, mulberry buffalo leather bags,etc. Mulberry oversized, Mulberry big size, Mulberry small size,etc. Welcome to our store, mulberry outlet all kinds of high quality mulberry bags to you, free shipping!
To find a suitable handbags is very important to people’s image, and where to find the most suitable bag to enhance self image? Mulberry Factory shop have full collection of Mulberry Bags let you choose. Luxury British top brand Mulberry own more than 100 years history and has long been recognized for its highly crafted fine leather goods. Use different materials design various Mulberry Bags to meet different people’s need, mulberry calf leather bags, mulberry patent leather bags, Mulberry Buffalo leather bags, Mulberry ostrich leather bags,etc. From oversized mulberry bags to small size mulberry bags, Mulberry Bags are very popular around the world. All kinds of Mulberry leather Bags with stylish style and fashion season, Mulberry Alexa Bags , Mulberry Bayswater Bags , Mulberry Mitzy Hobo , Mulberry Clutch Bags , Mulberry Handbags , Mulberry Mens Bags ,etc. Mulberry bag always keep pace with the trends of the times, so take mulberry leather bag will let you never out of date.
tn 2011
Tn foot locker
TN Requin
Nike TN
Nike TN Requin
Nike TN
Requin TN
TN Requin
Nike shox
TN REQUIN
Nike TN
Nike Requin
Chaussure Requin
Air Max Requin TN Pas Cher
Puma Pas Cher
Sac a main
Sac a main femme
sac a dos
valise
bagage à main et maroquinerie en ligne - Gsell
TN Nike
TN Requin
TN Pas Cher
TN Air Max
Nike tn 2012
tn foot locker
TN Pas Cher
Nike TN Pas Cher
دردشة بنات مصرية