Use local audio sources
authorCameron Ball <cameron@moodle.com>
Fri, 11 Dec 2020 09:30:10 +0000 (17:30 +0800)
committerCameron Ball <cameron@moodle.com>
Fri, 11 Dec 2020 09:30:10 +0000 (17:30 +0800)
audio/1.webm [new file with mode: 0644]
audio/2.webm [new file with mode: 0644]
index.html

diff --git a/audio/1.webm b/audio/1.webm
new file mode 100644 (file)
index 0000000..564abfb
Binary files /dev/null and b/audio/1.webm differ
diff --git a/audio/2.webm b/audio/2.webm
new file mode 100644 (file)
index 0000000..9198519
Binary files /dev/null and b/audio/2.webm differ
index 342b613..76ce926 100644 (file)
         </style>
          </head>
          <body>
-        <iframe width="560" height="315" id="audio" src="https://www.youtube.com/embed/B_QCJSTxqfI?controls=0&autoplay=1" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
         <div id="timer"></div>
+        <audio id="audio" autoplay>
+            <source id="audio/1.mp4" src="" type="audio/mp3" />
+        </audio>
         <video autoplay muted loop id="video">
             <source src="video/1.mp4" type="video/mp4">
         </video>
      var vidElement = document.getElementById('video');
      var activeVideo = Math.floor((Math.random() * 4) + 1);
      vidElement.src = "video/" + activeVideo + ".mp4";
-     vidElement.addEventListener('ended', function(e) {
-         // update the active video index
-         activeVideo = (++activeVideo) % vidSources.length;
-         if(activeVideo === vidSources.length){
-             activeVideo = 0;
-         }
-
-         vidElement.src = vidSources[activeVideo];
-         vidElement.play();
-     });
 
-     var vid = document.getElementById("video");
-     vid.playbackRate = 0.5;
-
-     var youtubeIds = ['VG1gcnCVJ8M', 'B_QCJSTxqfI'];
-     var youtubeId = youtubeIds[Math.floor(Math.random() * youtubeIds.length)];
-     var iframe = document.getElementById('audio');
-     iframe.src = "https://www.youtube.com/embed/" + youtubeId + "?controls=0&autoplay=1"
+     var audioElement = document.getElementById('audio');
+     var activeAudio = Math.floor((Math.random() * 2) + 1);
+     audioElement.src = "audio/" + activeAudio + ".webm";
 
      function pad(n, width, z) {
          z = z || '0';
      function tick() {
          var timespan = countdown(null, new Date('January 4, 2021 03:47:00'), countdown.ALL);
          var text = timespan.value < 0 ? '<span class="num">Welcome to Perth!</span>' : units.reduce((c, v) => c + formatUnit(timespan, v), "");
-     timerElement.innerHTML = text;
-     setTimeout(tick, delay);
+         timerElement.innerHTML = text;
+         setTimeout(tick, delay);
      }
 
      setTimeout(tick, delay);