diff --git a/35c3-video/index.html b/35c3-video/index.html index 4cba487..e908af9 100644 --- a/35c3-video/index.html +++ b/35c3-video/index.html @@ -61,13 +61,17 @@ var video = document.createElement('video'); video.setAttribute('src', prefix + file + '.mp4'); video.autoplay = true; - video.loop = true; video.addEventListener('playing', function () { if (window.waitUntil) { return; } var now = new Date(); window.waitUntil = now.getTime() + ((video.duration - video.currentTime) * 1000); + if (window.parent) { + window.parent.postMessage({ + waitUntil: window.waitUntil, + }, '*'); + } }); document.body.appendChild(video); diff --git a/infodisplay/infodisplay.js b/infodisplay/infodisplay.js index 0f252d4..5f1364a 100644 --- a/infodisplay/infodisplay.js +++ b/infodisplay/infodisplay.js @@ -62,6 +62,7 @@ function DisplayParticipant(broker, role, defaultUrls, timer) { callback('opened', null, next.getAttribute('src')); return; } + window.onmessage = null; next.onerror = (err) => { next.onload = null; next.onerror = null; @@ -80,6 +81,21 @@ function DisplayParticipant(broker, role, defaultUrls, timer) { timeout = setTimeout(() => { participant.send('open', getRotationUrl(urls, indata)); }, timer); + window.onmessage = (event) => { + window.onmessage = null; + const now = new Date(); + if (!event.data + || !event.data.waitUntil + || event.data.waitUntil < now.getTime()) { + return; + } + if (timeout) { + clearTimeout(timeout); + } + timeout = setTimeout(() => { + participant.send('open', getRotationUrl(urls, indata)); + }, event.data.waitUntil - now.getTime()); + }; callback('opened', null, next.getAttribute('src')); }; next.setAttribute('src', indata); diff --git a/video/index.html b/video/index.html index 0a21d38..15b39aa 100644 --- a/video/index.html +++ b/video/index.html @@ -61,13 +61,17 @@ var video = document.createElement('video'); video.setAttribute('src', prefix + file + '.mp4'); video.autoplay = true; - video.loop = true; video.addEventListener('playing', function () { if (window.waitUntil) { return; } var now = new Date(); window.waitUntil = now.getTime() + ((video.duration - video.currentTime) * 1000); + if (window.parent) { + window.parent.postMessage({ + waitUntil: window.waitUntil, + }, '*'); + } }); document.body.appendChild(video);