Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://www.modernizr.com/" rel="noreferrer">Modernizr</a> worked like a charm for me.</p> <p>What I did is that I didn't use <code>&lt;source&gt;</code>. Somehow this screwed things up, since the video only worked the first time load() was called. Instead I used the source attribute inside the video tag -> <code>&lt;video src="blabla.webm" /&gt;</code> and used <a href="http://www.modernizr.com/" rel="noreferrer">Modernizr</a> to determine what format the browser supported.</p> <pre><code>&lt;script&gt; var v = new Array(); v[0] = [ "videos/video1.webmvp8.webm", "videos/video1.theora.ogv", "videos/video1.mp4video.mp4" ]; v[1] = [ "videos/video2.webmvp8.webm", "videos/video2.theora.ogv", "videos/video2.mp4video.mp4" ]; v[2] = [ "videos/video3.webmvp8.webm", "videos/video3.theora.ogv", "videos/video3.mp4video.mp4" ]; function changeVid(n){ var video = document.getElementById('video'); if(Modernizr.video &amp;&amp; Modernizr.video.webm) { video.setAttribute("src", v[n][0]); } else if(Modernizr.video &amp;&amp; Modernizr.video.ogg) { video.setAttribute("src", v[n][1]); } else if(Modernizr.video &amp;&amp; Modernizr.video.h264) { video.setAttribute("src", v[n][2]); } video.load(); } &lt;/script&gt; </code></pre> <p>Hopefully this will help you :)</p> <p>If you don't want to use <a href="http://www.modernizr.com/" rel="noreferrer">Modernizr</a> , you can always use <a href="http://www.w3.org/TR/2011/WD-html5-20110113/video.html#dom-navigator-canplaytype" rel="noreferrer">CanPlayType()</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload