From ad591b543f3b537ece4b160a28e30b2256c7229d Mon Sep 17 00:00:00 2001 From: Derpimus - Liam Raithel <76272488+lraithel15133@users.noreply.github.com> Date: Tue, 6 Feb 2024 18:55:03 -0600 Subject: [PATCH] Update random_video.js --- videos/random_video.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/videos/random_video.js b/videos/random_video.js index 5f25199..fd78791 100644 --- a/videos/random_video.js +++ b/videos/random_video.js @@ -8,14 +8,25 @@ window.addEventListener("DOMContentLoaded", function () { function createSource(video, mimetype) { var source = document.createElement("source"); source.src = video; - source.mimetype = mimetype; + source.type = mimetype; return source; } function randomVideo() { var video = videos[Math.floor(Math.random() * videos.length)]; - videoTag.src = "videos/" + video + ".webm"; + + videoTag.innerHTML = ''; + + + var webmSource = createSource(`videos/${video}.webm`, 'video/webm'); + var mp4Source = createSource(`videos/${video}.mp4`, 'video/mp4'); + + + videoTag.appendChild(webmSource); + videoTag.appendChild(mp4Source); + + videoTag.load(); // Important to reload the video tag to apply new sources } videoTag.addEventListener("ended", randomVideo); randomVideo();