I am trying to display subtitles for sound recording using the webvtt element:
<audio controls="controls">
<source src="TheBrigands.mp3" />
<source src="TheBrigands.ogg" />
<track default="" kind="subtitles" srclang="en" label="English text" src="TheBrigands.vtt" />
</audio>
<div id="display">
It was a cold and stormy night,
</div>
Filling the display div with this script:
<script>
function main() {
var recording = document.querySelector("audio");
var track = recording.textTracks[0];
var display = document.getElementById("display");
track.mode = "hidden";
track.oncuechange = function () {
var cue = this.activeCues[0];
display.innerHTML = cue.text;
}
}
window.onload = main;
</script>
but when I check the track in firefox, although it has a cue object, it is empty:
document.querySelector('track').track.cues
TextTrackCueList { length: 0 }
I checked and I correctly configured the mime type on the server.
What am I missing so that it does not boot?
source
share