I want to set the time position of a video in HTML5. The time should be set like this:
function settime(){ var video = document.getElementById("video1"); console.log(video.currentTime); //----->output for example 15.3 video.currentTime = 10.0; console.log(video.currentTime);//----->>output always 0 }
And the video is embedded like this:
<button onclick="settime();">Set Time</button> <div class="container"> <video id="video1" class="video-js vjs-default-skin" muted> <source src="video.m4v" type="video/mp4" /> HTML5 Video is required for this example. </video>
But for some reason, this always just resets currentTime to 0 in Chrome.
Why gets the time reset when setting currentTime? And how can I set currentTime correctly?
If your browser error "HTML5 video file not found", it means that your browser is not up to date or website pages does not have a suitable video codec. It would help if you communicated with the developer to solve the issue and install all the required codecs.
All modern full-feature browsers will play HTML5 video. That includes Google Chrome, all Chromium-based browsers such as Brave and the new version of Microsoft Edge, Firefox, Safari, and the older non-Chromium version of Edge.
An HTML5 video player is a digital technology that allows broadcasters to share video content with users over the internet. The HTML5 streaming technology was created as a more widely compatible alternative to Adobe's Flash player.
<video>: The Video Embed element. The <video> HTML element embeds a media player which supports video playback into the document.
This is caused in many cases by the server not replying with an Accept-Ranges
header. For an obscure, only-Google-developer-relevant reason (the FF folks don't seem to be so offended by a server replying without an Accept-Ranges
header), they refuse to implement seeking when such a header is not provided. You can add one very easily (at least for testing) by using an nginx proxy and adding proxy_force_ranges on;
(server or location both work).
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