allows continuing and stopping of audio, with slightly strange semantics

This commit is contained in:
Sanjay Bhangar 2018-03-16 19:20:00 +05:30
parent 8d4f7be7a5
commit 65378ee564
2 changed files with 17 additions and 2 deletions

View File

@ -1,6 +1,7 @@
var slides = [],
slideData = [],
current = 0,
activeAudio,
timeout;
@ -58,6 +59,9 @@ function start(idx) {
} else if (data.video && data.video.length) {
start_video(data)
}
if (data.audioContainer) { // if there is an audio container, we always stop current audio
reset_active_audio();
}
if (data.audio) {
start_audio(data)
}
@ -71,7 +75,7 @@ function stop(idx) {
} else if (data.video && data.video.length) {
reset_video(data)
}
if (data.audio) {
if (data.audio && !data.audioContinue) {
reset_audio(data)
}
}
@ -102,6 +106,8 @@ function load_slide(slide) {
if (audio) {
data.audio = audio.dataset.url // audio does not need to be an array
data.audioContainer = audio
console.log('continue', audio.dataset.continue)
data.audioContinue = !!audio.dataset.continue
}
return data
}
@ -175,6 +181,7 @@ function start_audio(data) {
data.audioEmbed.postMessage('options', {
'paused': false
})
activeAudio = data
}
function reset_video(data) {
@ -189,6 +196,13 @@ function reset_audio(data) {
'paused': true,
'position': 0 //FIXME: figure correct audio reset
})
activeAudio = null;
}
function reset_active_audio() {
if (activeAudio) {
reset_audio(activeAudio)
}
}
document.addEventListener('keydown', function(event) {

View File

@ -10,7 +10,7 @@
<div class="title">
At first, three stories from the year 1950 in Bombay
</div>
<div class="audio" data-url="https://pad.ma/BVF/editor/F#embed"></div>
<div class="audio" data-continue="true" data-url="https://pad.ma/BVF/editor/F#embed"></div>
</div>
<div class="slide" data-duration="10">
<div class="title">
@ -25,6 +25,7 @@
data-url_0="https://pad.ma/documents/AFL/0,0,6580,3763#embed"
data-url_1="https://pad.ma/documents/AFL/1568,1461,3352,2401#embed"
></div>
<div class="audio"></div> <!-- signal to stop playing audio -->
</div>
<div class="slide" data-duration="10">
<div class="title">