I don't like this way of doing record position

This commit is contained in:
Thomas Forgione 2021-03-24 08:18:46 +01:00
parent c28f3ef9ae
commit 28f6c05acb
1 changed files with 1 additions and 11 deletions

View File

@ -23,8 +23,7 @@
if (app.ports !== undefined && app.ports.registerVideo !== undefined) { if (app.ports !== undefined && app.ports.registerVideo !== undefined) {
app.ports.registerVideo.subscribe(function(args) { app.ports.registerVideo.subscribe(function(args) {
window.scrollTo(0, 0); window.scrollTo(0, 0);
var time = vd.parseTime(args[2]); var time = vd.parseTime(args[2]) || undefined;
time = time || vd.parseTime(localStorage.getItem(args[0]));
requestAnimationFrame(function() { requestAnimationFrame(function() {
if (args[0] !== lastId) { if (args[0] !== lastId) {
@ -39,8 +38,6 @@
player.currentTime(time); player.currentTime(time);
} }
}); });
setTimeout(recordPosition, 1000);
}); });
} }
@ -50,13 +47,6 @@
lastId = undefined; lastId = undefined;
}); });
} }
function recordPosition() {
if (lastId !== undefined) {
localStorage.setItem(lastId, player.currentTime());
setTimeout(recordPosition, 1000);
}
}
</script> </script>
</body> </body>
</html> </html>