video auutoplay, reset video

This commit is contained in:
Sanjay Bhangar 2018-03-09 22:11:27 +05:30
parent 54896ff1c3
commit bc374ef513

View File

@ -9,7 +9,8 @@ init()
function init() {
document.querySelectorAll('.slide').forEach(function(slide) {
slides.push(slide)
var data = slideData[slides.length - 1] = load_slide(slide)
var data = slideData[slides.length - 1] = load_slide(slide);
data.idx = slides.length - 1;
if (data.video && data.video.length) {
data.embed = init_embed(data)
}
@ -26,7 +27,7 @@ function go(idx) {
clearTimeout(timeout)
timeout = null
}
//timeout = setTimeout(next, Math.round(slides[current].dataset.duration) * 1000)
timeout = setTimeout(next, Math.round(slides[current].dataset.duration) * 1000)
//
stop(old)
start(current)
@ -62,7 +63,7 @@ function stop(idx) {
if (data.zoom_to) {
reset_zoom(data)
} else if (data.video && data.video.length) {
pause_video(data)
reset_video(data)
}
}
@ -93,12 +94,19 @@ function load_slide(slide) {
function init_embed(data) {
var embed = window.currentEmbed = new PandoraEmbed({
id: 'fixme',
id: 'slide-' + data.idx,
url: data.video[0],
container: data.container
});
embed.on('init', function(data) {
});
embed.on('playing', function(positionData) {
if (!slideData[data.idx].start) {
slideData[data.idx].start = positionData.position;
}
});
return embed;
}
@ -135,9 +143,10 @@ function start_video(data) {
})
}
function pause_video(data) {
function reset_video(data) {
data.embed.postMessage('options', {
'paused': true
'paused': true,
'position': data.start || 0
})
}