allow setting of volume via data-volume

This commit is contained in:
Sanjay Bhangar 2018-03-16 20:00:57 +05:30
parent 79c00627a3
commit 18cdcee3c1
2 changed files with 8 additions and 4 deletions

View File

@ -95,6 +95,7 @@ function load_slide(slide) {
var video = slide.querySelector('.video') var video = slide.querySelector('.video')
if (video) { if (video) {
data.video = load_urls(video.dataset) data.video = load_urls(video.dataset)
data.videoVolume = video.dataset.volume ? parseFloat(video.dataset.volume) : 1
data.container = video data.container = video
// assumes documents if length > 1 // assumes documents if length > 1
@ -105,6 +106,7 @@ function load_slide(slide) {
var audio = slide.querySelector('.audio') var audio = slide.querySelector('.audio')
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.audioVolume = audio.dataset.volume ? parseFloat(audio.dataset.volume) : 1
data.audioContainer = audio data.audioContainer = audio
console.log('continue', audio.dataset.continue) console.log('continue', audio.dataset.continue)
data.audioContinue = !!audio.dataset.continue data.audioContinue = !!audio.dataset.continue
@ -173,13 +175,15 @@ function start_zoom(data) {
function start_video(data) { function start_video(data) {
data.embed.postMessage('options', { data.embed.postMessage('options', {
'paused': false 'paused': false,
'volume': data.videoVolume
}) })
} }
function start_audio(data) { function start_audio(data) {
data.audioEmbed.postMessage('options', { data.audioEmbed.postMessage('options', {
'paused': false 'paused': false,
'volume': data.audioVolume
}) })
activeAudio = data activeAudio = data
} }

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-continue="true" data-url="https://pad.ma/BVF/editor/F#embed"></div> <div class="audio" data-volume="0.4" 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">
@ -37,7 +37,7 @@
></div> ></div>
</div> </div>
<div class="slide" data-duration="15"> <div class="slide" data-duration="15">
<div class="video" data-url_0="https://pad.ma/BVF/editor/F#embed" <div class="video" data-volume="0.9" data-url_0="https://pad.ma/BVF/editor/F#embed"
></div> ></div>
</div> </div>