Does the normal YouTube player (by normal I mea开发者_Go百科n the one you get when you use the embed code iframe
) fire an event when playback is completed that I can catch outside the iframe
?
As normal cross-domain javascript communication is restricted for security reasons this is not 'normally' possible.
In modern, HTML5 compliant, browsers a new method was introduced: postMessage
. To be able to do exactly that: safe cross-domain communication in Javascript.
The iframe
YouTube player 'posts' out an onStateChanged
event with different stati. To enable this interaction however, you need to use Javascript to embed the iframe
player.
Check out the following link to see how it's done. (Experimental feature by the way...)
http://code.google.com/intl/nl/apis/youtube/iframe_api_reference.html
精彩评论