Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does setting currentTime of HTML5 video element reset time in Chrome?

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?

like image 552
user2212461 Avatar asked Apr 22 '16 02:04

user2212461


People also ask

Why is my video not working in HTML5?

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.

Does the Chrome support video tag in HTML?

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.

What is HTML5 playback?

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.

What is the correct HTML5 element for playing video?

<video>: The Video Embed element. The <video> HTML element embeds a media player which supports video playback into the document.


1 Answers

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).

like image 127
AntonOfTheWoods Avatar answered Sep 19 '22 08:09

AntonOfTheWoods