Youtube API how to play video from 0 seconds when video ends? Iframe, Javascript -


so have code detects when player has stopped problem can't play 0 seconds when end has come i'm using iframe embed holds html5 video, here code!

<div id="youtube-fs"><iframe id="youtube-iframe" type="text/html" src="http://www.youtube.com/embed/lyl0lzmrvk8?enablejsapi=1&html5=1&autoplay=1&showinfo=0&controls=0&rel=0&wmode=transparent&vq=hd1080&hd=1&loop=1" frameborder="0" wmode="opaque" ></iframe> <script type="text/javascript">     <!--       var tag = document.createelement('script');       tag.src = "http://www.youtube.com/player_api";       var firstscripttag = document.getelementsbytagname('script')[0];       firstscripttag.parentnode.insertbefore(tag, firstscripttag);       var player;       function onyoutubeplayerapiready() { player = new yt.player('youtube-iframe', { events: { 'onstatechange': onplayerstatechange } }); }       function onplayerready(event) { event.target.playvideo(); }       function onplayerstatechange(event) {         if (event.data == yt.playerstate.ended) { player.playvideoat(0); } // play 0 seconds       }         -->     </script>      </div> 

any idea's? maybe seekto? or thank in advance!

used player.seekto(1, true); worked

try this

 function onplayerstatechange(event) {         if (event.data == yt.playerstate.ended) {            player.seekto(0);            player.playvideo();          } // play 0 seconds       } 

http://plnkr.co/aosupft7vxggom99snwl


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -