basic audio working without continue

This commit is contained in:
Sanjay Bhangar 2018-03-16 18:25:14 +05:30
parent 034832f71e
commit 8d4f7be7a5
3 changed files with 43 additions and 2 deletions

View File

@ -54,3 +54,7 @@ body {
margin: 0;
padding: 0;
}
.audio iframe {
height: 0;
}

View File

@ -14,6 +14,9 @@ function init() {
if (data.video && data.video.length) {
data.embed = init_embed(data)
}
if (data.audio) {
data.audioEmbed = init_audio_embed(data)
}
})
go(0)
}
@ -55,6 +58,9 @@ function start(idx) {
} else if (data.video && data.video.length) {
start_video(data)
}
if (data.audio) {
start_audio(data)
}
}
function stop(idx) {
@ -65,6 +71,9 @@ function stop(idx) {
} else if (data.video && data.video.length) {
reset_video(data)
}
if (data.audio) {
reset_audio(data)
}
}
function load_urls(dataset) {
@ -89,6 +98,11 @@ function load_slide(slide) {
data.zooms = data.video.map(url => url.split('/').pop().split('#')[0].split(',').map(a => Math.round(a)))
}
}
var audio = slide.querySelector('.audio')
if (audio) {
data.audio = audio.dataset.url // audio does not need to be an array
data.audioContainer = audio
}
return data
}
@ -110,6 +124,14 @@ function init_embed(data) {
return embed;
}
function init_audio_embed(data) {
return new PandoraEmbed({
id: 'slide-audio-' + data.idx,
url: data.audio,
container: data.audioContainer
})
}
window.addEventListener('blur', function(){
setTimeout(function(){
// using the 'setTimout' to let the event pass the run loop
@ -149,6 +171,12 @@ function start_video(data) {
})
}
function start_audio(data) {
data.audioEmbed.postMessage('options', {
'paused': false
})
}
function reset_video(data) {
data.embed.postMessage('options', {
'paused': true,
@ -156,6 +184,13 @@ function reset_video(data) {
})
}
function reset_audio(data) {
data.audioEmbed.postMessage('options', {
'paused': true,
'position': 0 //FIXME: figure correct audio reset
})
}
document.addEventListener('keydown', function(event) {
if (event.key == 'ArrowRight') {
next()

View File

@ -3,13 +3,14 @@
<link type="text/css" href="example.css" rel="stylesheet" />
<div class="base">
</div>
<div class="slide" data-duration="5">
<div class="slide" data-duration="10">
<div class="title">FROM JANTA COLONY TO JANTA COLONY</div>
</div>
<div class="slide" data-duration="5">
<div class="slide" data-duration="10">
<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>
<div class="slide" data-duration="10">
<div class="title">
@ -37,6 +38,7 @@
<div class="slide" data-duration="15">
<div class="video" data-url_0="https://pad.ma/BVF/editor/F#embed"
></div>
</div>
<div class="slide" data-duration="15">
<div class="video" data-url_0="https://indiancine.ma/AKDP/editor/BFR#embed"