JSFiddle - React, Tailwind, and code Playground
by lastrose
HTML
<audio id="clip" preload="auto" tabindex="0" controls="" >
<source src="http://www.archive.org/download/bolero_69/Bolero.mp3">
Your Fallback goes here
</audio>
JavaScript
var count = 1;
var clipstart = [0,10,20,30,40,50,60];
var clipend = [5,15,25,35,45,55,65];
var clip = document.getElementById('clip');
var end;
var start;
function stop(){
if(clip.currentTime >= end){
console.log(end);
console.log(clip.currentTime);
clip.pause();
if(!(count == 1 && clipstart.length == 0)){
skip();
}
}
}
function play(){
clip.currentTime = start;
clip.play();
}
function skip(){
count++;
if(count == 2){
count = 0;
start = clipstart.shift();
end = clipend.shift();
}
play();
}
skip();
clip.addEventListener('timeupdate', stop);