Commit 9d5fa494 authored by i❤computers's avatar i❤computers

Add the ability to click anywhere within the article to start from that point

parent f3139bda
......@@ -16,7 +16,21 @@ document.addEventListener('DOMContentLoaded', function initializePage() {
}
});
$('article').on('click', function playAudio() {
$('article').on('click', function playFromCue(event) {
var target = event.target;
var cuePositionName = target.dataset.cuePosition;
if (cuePositionName) {
playAudio(transcriptCuesTrack.filter(function (cueTrack) {
return cueTrack.cuePositionName.localeCompare(cuePositionName) === 0;
})[0].cueTime);
}
});
audio.on('ended', resetPlayer);
function playAudio(startTime) {
if (startTime) {
audio.currentTime = startTime;
}
if (audio.paused || audio.ended) {
audio.play().then(function () {
requestAnimationFrame(updateHighlight);
......@@ -25,8 +39,7 @@ document.addEventListener('DOMContentLoaded', function initializePage() {
audio.pause();
resetPlayer();
}
});
audio.on('ended', resetPlayer);
}
var currentTranscriptIndex = 0;
var HIGHLIGHTED_CLASS = "highlighted";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment