Javascript – Firing javascript on embedded video end of playback


Im writing a page that will display a video, and on playback completion, will display a code that can be turned in as proof of watching the video. I was thinking I could do this in javascript, but after a few quick google searches, I haven't come up with anything. Is there any way for javascript to listen for the end of playback of embedded media, then fire a function when that occurs?

Alternatively, I've considered using a timer and just have the script fire after the an amount of time has passed equal to the length of the video.

What do you think?

Thanks in advance!

Here's the actual embed code in case it helps anyone:

<object data="video.swf" width="704" height="480" type="application/x-shockwave-flash">
<param name="pluginspage" value="" />
<param name="autoplay" value="true" />
<param name="loop" value="false" />

Best Solution

Typically this is done by having your flash code call a javascript function when it is complete.