Last active
July 18, 2024 04:31
-
-
Save nullivex/7a0b26a466cf68f92bb6845eab7c12d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var currentPosition = 0; | |
if (localStorage.currentPlayerPosition) { | |
currentPosition = localStorage.currentPlayerPosition; | |
} | |
player.once('play', function (){ | |
'use strict'; | |
if (currentPosition > 0 && Math.abs(player.getDuration() - currentPosition) > 5) { | |
player.seek(currentPosition); | |
} | |
}) | |
window.onunload = function (){ | |
localStorage.currentPlayerPosition = player.getPosition(); | |
} | |
player.on('error', function (e){ | |
console.log(e); | |
localStorage.currentPlayerPosition = player.getPosition(); | |
window.localhost.reload(true); | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This assumes your player is loaded to the
player
variable if it isnt do the following first.var player = jwplayer();