javascript - YouTube Video restarts when hiding and showing its container div -


i have youtube video embedded in page inside of div can hidden , shown button (using jquery/css). when hide , show show div video has reload , start form beginning. there way remember video's progress , playback form same position? or better yet way that video not have reload?

here html5 div/you-tube video:

    <div id="you-tube-div">        <object width="640" height="390" data="http://www.youtube.com/v/fq2lnln2bok" type="application/x-shockwave-flash">           <param name="src" value="www.youtube.com/v/fq2lnln2bok"/>        </object>     </div> 

edit:

here little jfiddle shows trying do:

http://jsfiddle.net/ntk3b/

i recommend converting object embed newer iframe element embedding youtube video. using code stackoverflow post: how pause youtube player when hiding iframe?

//via: https://stackoverflow.com/questions/8667882/how-to-pause-a-youtube-player-when-hiding-the-iframe function togglevideo(state) {     // if state == 'hide', hide. else: show video     var div = document.getelementbyid("you-tube-div");     var iframe = div.getelementsbytagname("iframe")[0].contentwindow;     div.style.display = state == 'hide' ? 'none' : '';     func = state == 'hide' ? 'pausevideo' : 'playvideo';     iframe.postmessage('{"event":"command","func":"' + func + '","args":""}', '*'); } 

i've created fiddle want: http://jsfiddle.net/rsdxc/2/


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -