detect when youtube video ends - javascript - not working -


I have youtube video db (URL only) i are in this form:

< / P>

Now, I have to find out that when the video is over and there is something more to show in place of the video container.

I tried these steps:

  1 The above YouTube URL has been changed to:  

  2 Videopage.html Added this JS code to var player; Function onYouTubePlayerAPIReady () {Warning ('API ready!'); Player = new YT.Player ('player', {event: {'ontet change': onplayerstate change}}); } // When PlayerSteet Changes (Event) ends on the video {if (event.data === 0) {Warning ('done'); }}  

but I am not "API is getting ready!" and "done" alert. What am I doing wrong?

It was easy:

  var tag = document.createElement ( 'Script'); Tag src = "https://www.youtube.com/iframe_api"; Var firstScriptTag = document.getElementsByTagName ('script') [0]; FirstScriptTag.parentNode.insertBefore (tag, firstScriptTag); Var player; YouTube IFrame on Function () {player = New YT.Player ('myyoutubevideo_iframe_div', {height: '410', width: '100%', Video: '{{video.yt_id}}', Event: {'On-Ed ': OnPlayerReady,' Onestate Change ': Onplayerstate Change}}); }player read (event) on function {event.target.playVideo (); } Var done = false; Function on playerstate change (event) {if (event.data == YT.PlayerState.ENDED) {$ ('# myyoutubevideo_iframe_div'). Hide (); $ ('# Aftervideo_div') Show (). }}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -