Allows for audio tracks on slides #4

Merged
j merged 2 commits from add-audio into master 2018-03-16 14:10:55 +00:00
2 changed files with 17 additions and 2 deletions
Showing only changes of commit 65378ee564 - Show all commits

View File

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

View File

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