The following works in Chrome but not Firefox:
var myVideo = document.getElementById('myVideo')
myVideo.currentTime = 570
<video id="myVideo" controls>
<source src="myVideo.mp4" type="video/mp4">
</video>
In Firefox it says
InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable
for line 2.
That error occurs when the object, in this case the video, hasn't loaded enough to be able to set the currentTime
and skip forward.
You'd have to wait until the video can be played before you can set the currentTime
var myVideo = document.getElementById('myVideo')
myVideo.addEventListener('canplaythrough', function() {
myVideo.currentTime = 570;
}, false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With