I have the following object which defines the end and start times for a paragraph:
var times = {
"p1": [24.500, 29.268],
"p2": [29.268, 29.441],
"p3": [29.441, 29.640]
};
I wish to call updateCurrentParagraph
when the paragraph changes:
vid.addEventListener("timeupdate", function() {
var t = this.currentTime;
for (var key in times) {
if (t >= times[key][0] && t < times[key][1])
{
updateCurrentParagraph(key);
return;
}
}
// at end of audio
if (times[times.length-1][1] == t){
updateCurrentParagraph(???);
return;
}
updateCurrentParagraph("unknown");
return;
});
What do I do at ???
to get "p3"?