From 8d4f7be7a5cdd94d32bb862c64e1e61c75cc1896 Mon Sep 17 00:00:00 2001 From: Sanjay Bhangar Date: Fri, 16 Mar 2018 18:25:14 +0530 Subject: [PATCH] basic audio working without continue --- example/example.css | 4 ++++ example/example.js | 35 +++++++++++++++++++++++++++++++++++ example/index.html | 6 ++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/example/example.css b/example/example.css index f9ca359..5c9fb53 100644 --- a/example/example.css +++ b/example/example.css @@ -54,3 +54,7 @@ body { margin: 0; padding: 0; } + +.audio iframe { + height: 0; +} diff --git a/example/example.js b/example/example.js index f415a02..7e0720c 100644 --- a/example/example.js +++ b/example/example.js @@ -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() diff --git a/example/index.html b/example/index.html index 18490c3..f946d80 100644 --- a/example/index.html +++ b/example/index.html @@ -3,13 +3,14 @@
-
+
FROM JANTA COLONY TO JANTA COLONY
-
+
At first, three stories from the year 1950 in Bombay
+
@@ -37,6 +38,7 @@
+