javascript - Video HTML5 / wait until Readystate === 4 then playvideo in loop -
Hello I look a little bit to find a solution, but as I'm beginning in JavaScript I am the solution to the problem :
I have two videos (OGV for Firefox):
& lt; Video Loop Poster = "Picture / Poster Gif" & gt; & Lt; Source src = "video / bg-4.mp4" type = "video / mp34" & gt; & Lt; Source src = "video / bg-4.ogv" type = "video / og" & gt; & Lt; / Video & gt; I want to check whether they are loaded and after the autoplay they tried it in the loop (as background video) but this does not work: function autoplay () {var v = document.getElementsByTagName ("video") [0]; If (v.readyState === 4) {v.play (); } } auto play(); Just add this attribute to the video tag: & lt; Video Loop Poster = "images / poster.gif" Autoplay & gt; & Lt; Source src = "video / bg-4.mp4" type = "video / mp34" & gt; & Lt; Source src = "video / bg-4.ogv" type = "video / og" & gt; & Lt; / Video & gt;
Comments
Post a Comment