ended - seeked infinite loop
Minimal JS reproduction for the Flutter web PR:
https://github.com/flutter/packages/pull/5920
by David Iglesias
HTML
<small>(Look at the JS console!)</small>
<video controls autoplay muted src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4" id="player"></video>
CSS
video {
max-width: 100%;
max-height: 100%;
}
JavaScript
// Logs some common events, with a timestamp
['seeked', 'paused', 'ended', 'playing'].forEach((evt) => { player.addEventListener(evt, log) });
// Reproduces the issue
player.addEventListener('ended', (_) => {
if (inInfiniteLoop()) {
console.log('* Stopping infinite loop');
return;
}
// Causes infinite loop 'seeked' - 'ended'
player.currentTime = player.duration;
});
function log(e) {
console.log(new Date().getTime(), e.type);
}
// Solves the Entscheidungsproblem
function inInfiniteLoop() {
if (counter++ >= 20) {
counter = 0;
return true;
}
return false;
}
let counter = 0;