0

According to the documentation

calling an embed with the url http://www.youtube.com/v/VIDEO_ID?version=3&enablejsapi=1 should trigger the callback onYouTubePlayerReady() when the video is ready. I have tried to achive this like this:

<body>
<iframe id="ytplayer" type="text/html" width="100%" height="56.25"
                src="http://www.youtube.com/v/M7lc1UVf-VE?version=3&enablejsapi=1&playerapiid=ytplayer"
                frameborder="0" allowfullscreen></iframe>
</body>

Javascript:

function onYouTubePlayerReady(playerID){
    console.log(playerID);
    console.log('working');
    alert('working');
}

But the callback isn't triggered, see js-fiddle: what am i doing wrong?

http://jsfiddle.net/B85p5/1/

Himmators
  • 14,278
  • 36
  • 132
  • 223
  • To test any of these calls, you must have your file running on a webserver, as the Flash player restricts calls between local files and the internet. – Mark Oct 07 '13 at 12:42
  • It's likely because it's in an iframe. You want the swobject on this page. – stevemarvell Oct 07 '13 at 12:44
  • don't forget allowScriptAccess when you do it – stevemarvell Oct 07 '13 at 12:46
  • seems it's duplicate, please refer this link http://stackoverflow.com/questions/15003597/why-isnt-the-youtube-iframe-player-calling-onyoutubeplayerready-when-its-loade – Sheeban Singaram Oct 07 '13 at 12:47
  • hi u just want autoplay the video is that wat u need. – codebreaker Oct 07 '13 at 12:52
  • @codebreaker unfortunately, I need an event to trigger when the video has stopped playing. – Himmators Oct 07 '13 at 14:28
  • hi u may have gone through this fiddle r not dono but stil this gives callback of youtube video and also this post will help ur cause..http://stackoverflow.com/questions/12107202/youtube-injected-video-ends-callback ..http://jsfiddle.net/vPELX/2/ – codebreaker Oct 08 '13 at 07:00

0 Answers0