Tengo este código
Código HTML:
<figure id="video_player"> <video controls autoplay poster="video1.jpg"> <source src="./videos/principal.mp4" type="video/mp4"> </video> <figcaption> <a href="./videos/video1.mp4"><img src="video1.jpg" alt="Video 1"></a> <a href="./videos/video2.mp4"><img src="video2.jpg" alt="Video 2"></a> <a href="./videos/video3.mp4"><img src="video3.jpg" alt="Video 3"></a> <a href="./videos/video3.mp4"><img src="vide4.jpg" alt="Video 4"></a> </figcaption> </figure> <script> var video_player = document.getElementById("video_player"); var links = video_player.getElementsByTagName('a'); var t; for (var i=0; i<links.length; i++) { links[i].onclick = handler; } function handler(e) { e.preventDefault(); videotarget = this.getAttribute("href"); filename = videotarget.substr(0, videotarget.lastIndexOf('.')) || videotarget; video = document.querySelector("#video_player video"); video.removeAttribute("controls"); video.setAttribute("poster","/assets/images/video-placeholder.png"); source = document.querySelectorAll("#video_player video source"); source[0].src = filename + ".mp4"; source[1].src = filename + ".webm"; video.load(); video.play(); } </script>