Allow videos to block rotation until they're finished

This commit is contained in:
Henri Bergius 2018-12-26 15:48:04 +01:00
parent 22212e5612
commit 8bc5c1167a
2 changed files with 14 additions and 0 deletions

View file

@ -78,6 +78,16 @@ function DisplayParticipant(broker, role, defaultUrls, timer) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
const now = new Date();
if (next.contentWindow
&& next.contentWindow.waitUntil
&& next.contentWindow.waitUntil > now.getTime()) {
// This view wants more time, let it run to completion
setTimeout(() => {
participant.send('open', getRotationUrl(urls, indata));
}, next.contentWindow.waitUntil - now.getTime());
return;
}
participant.send('open', getRotationUrl(urls, indata));
}, timer);
callback('opened', null, next.getAttribute('src'));

View file

@ -62,6 +62,10 @@
video.setAttribute('src', prefix + file + '.mp4');
video.autoplay = true;
video.loop = true;
video.addEventListener('playing', function () {
var now = new Date();
window.waitUntil = now.getTime() + ((video.duration - video.currentTime) * 1000);
});
document.body.appendChild(video);
var time = document.getElementById('current-time');