From 65378ee5645044ddc4949070e860523fcd8f876c Mon Sep 17 00:00:00 2001 From: Sanjay Bhangar Date: Fri, 16 Mar 2018 19:20:00 +0530 Subject: [PATCH] allows continuing and stopping of audio, with slightly strange semantics --- example/example.js | 16 +++++++++++++++- example/index.html | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/example/example.js b/example/example.js index 7e0720c..ac7c902 100644 --- a/example/example.js +++ b/example/example.js @@ -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) { diff --git a/example/index.html b/example/index.html index f946d80..c0b6d34 100644 --- a/example/index.html +++ b/example/index.html @@ -10,7 +10,7 @@
At first, three stories from the year 1950 in Bombay
-
+
@@ -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" >
+