Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've hacked together a working fiddle prototype; definitely not the most efficient it could be, but it works. <a href="http://jsfiddle.net/3BmDx/" rel="nofollow">http://jsfiddle.net/3BmDx/</a></p> <p>Basically, the way that it works is that the javascript will handle the clicks and will play all of the videos instead of using the 'autoplay' tag. You may want to look into pre-loading the videos before running that <code>.play()</code> for them. Something <em>like</em>:</p> <pre><code> var videos = 6; var loaded = 0; $(video).on("load", function() { loaded++; if(loaded==videos) { // all videos have been loaded on the page, now .play() them } } </code></pre> <p>jQuery is handy because if you want to apply a <code>.hide()</code> to all of the video elements on the page at once, you can simply use <code>$('video').hide()</code> and jQuery will match all video tags.</p> <p>I use this to my advantage in the <code>reset(b)</code> function. the <code>reset(b)</code> function is called each time a button click is pressed and it will re-enable all buttons, deactivate the current button (helpful for knowing which you selected) and then hide all the videos on the page. Afterward the correct video will be shown.</p> <pre><code> $(document).ready(function(){ // hide all of the video tags $("video").hide(); $("button").removeAttr("disabled"); $.each($("video"), function(i,e) { $(e)[0].play(); }); function reset(b) { $("button").removeAttr("disabled"); $(b).attr("disabled", "disabled"); $("video").hide(); } // handle button click for video to show $("#button1").click(function() { reset($(this)); $("#video1").show(); }); $("#button2").click(function() { reset($(this)); $("#video2").show(); }); $("#button3").click(function() { reset($(this)); $("#video3").show(); }); $("#button4").click(function() { reset($(this)); $("#video4").show(); }); $("#button5").click(function() { reset($(this)); $("#video5").show(); }); $("#button6").click(function() { reset($(this)); $("#video6").show(); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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