Moses
posted this on April 05, 2010 01:47 pm
You can control the Animoto Flash video player using JavaScript.
Note: Use this API at your own risk, there is a chance that it may be changed or unsupported in the future.
var player = document.getElementById("vp1fKSkZ");
If you want to change the id object/embed id you must add a custom flashvar called 'id' with the new value in both the object and embed tags.
We've found that using SWFObject is the best way to ensure that your embed will work correctly in all browsers and operating systems.
You should use the object/embed id as your div id, or if you use a custom id you should include a new flashvar 'id' referring to the new name.
Here's an example SWFObject embed. (Note that it's easiest to just paste the full swf url with flashvars. In the following example some of the url characters are replaced with spaces to prevent this wiki from generating a link, your url should not be reformatted in this way.)
swfobject.embedSWF( "http //p-static animoto com/swf/w.swf?w=swf/vp1&e=1239733952&f=gEAqirVa6E30h4RlCAuv0g&d=31&m=b&r=w&i=m&options=arthropod",
"vp1gEAqi", "432", "240" "9.0.115", false,
null, { allowFullScreen:true, allowScriptAccess:"always" }, null);
<div id="vp1gEAqi">Update your flash player.</div>
1. Wrap your call in a conditional statement that verifies the function exists. For example,
if (document.getElementById("vp1fKSkZ").playMedia) {
document.getElementById("vp1fKSkZ").playMedia();
}
2. Add a callback to the page called playerReady, and use this to set a variable indicating that it's safe to make calls to the player.
function playerReady(info) {
alert("Player " + info.id + " is ready!");
}
3. If you have more than one player on a page, either inspect the info object passed to the playerReady callback to get the specific player's id. Alternatively you can set a unique callback name in each embed using the custom flashvar ready_callback (be sure to add this to both the object and embed tags in each embed instance).
function playerReady(info) {
if (info.id == "vp1fKSkZ") {
alert("Primary player is ready");
}
else if (info.id == "vp1fKSkZ") {
alert("Secondary player is ready");
}
}
playMedia(); // makes video start playing
pauseMedia(); // pauses video
toggleMediaPlay(); // plays or pauses depending on current play state
seekMedia(seconds); // seeks video to position (if it has loaded to that point)
setVolume(0..100); // sets player volume, for example pass 0 to mute player.
The getState method lets you check the current play state the player is in. Note that the state 'BUFFERING' is equivalent to 'PLAYING', and the state 'COMPLETED' is equivalent to 'IDLE' but means the video has recently finished playing.
getState();
returns: 'IDLE' | 'BUFFERING' | 'PLAYING' | 'PAUSED' | 'COMPLETED'
We've made an effort to keep things simple here, but if this document did not address your specific needs please feel free to drop us a support request.