I've got 2500 transcripts with time stamps every 3 minutes. I want the time stamps to jump to the time in the audio file.
I'm using Javascript and HTML5 and have the code pieces working but not the whole thing.
<script>
function initAudio(){
var speedlist = document.getElementById("speedlist");
speedlist.addEventListener("change",changeSpeed);
function changeSpeed(event){
myAudio.playbackRate = event.target.value;
}
function setCurrentTime(event){
myAudio.currentTime = event.target.value;
}
function hmsToSecondsOnly(str) {
var p = str.split(':'),
s = 0, m = 1;
while (p.length > 0) {
s += m * parseInt(p.pop(), 10);
m *= 60;
}
return s;
}
}
window.addEventListener("load", initAudio);
</script>
<font size="2px"> .5 x
<input id="speedlist" type="range" value="1" min="0.5" max="2.5" step="0.1" width="100px"> 2.5 x </font>
<img title="Reset Audio Speed to 1 x" src="https://pocketcollege.com/Speed.png" onclick="myAudio.playbackRate = 1"></p>
<audio id="myAudio" controls preload="metadata" style="width:100%;">
<source src="https://pocketcollege.com/mp3/RR100A1.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<input type="button" value="[3:13]" onclick="myAudio.currentTime=200">
<input type="button" value="[6:27]" onclick="setCurrentTime(hmsToSecondsOnly('6:27'))">
The first button works and moves the time to 3 minutes 20 seconds. The second button has no effect.