Use postMessage for communicating waitUntil
This commit is contained in:
parent
173311ed33
commit
8fd8d7a3bd
3 changed files with 26 additions and 2 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue