I'm having issues seeking in video's using Chrome.
For some reason, no matter what I do, video.seekable.end(0)
is always 0.
When I call video.currentTime = 5
, followed by console.log(video.currentTime)
, I see it is always 0, which seems to reset the video.
I've tried both MP4 and VP9-based webm formats, but both gave the same results.
What's more annoying is that Firefox runs everything perfectly. Is there something special about Chrome that I should know about?
Here's my code (which only works in Firefox):
<div class="myvideo"> <video width="500" height="300" id="video1" preload="auto"> <source src="data/video1.webm" type="video/webm"/> Your browser does not support videos. </video> </div>
And here's the javascript:
var videoDiv = $(".myvideo").children().get(0) videoDiv.load(); videoDiv.addEventListener("loadeddata", function(){ console.log("loaded"); console.log(videoDiv.seekable.end(0)); //Why is this always 0 in Chrome, but not Firefox? videoDiv.currentTime = 5; console.log(videoDiv.currentTime); //Why is this also always 0 in Chrome, but not Firefox? });
Note that simply calling videoDiv.play()
does actually correctly play the video in both browsers.
Also, after the movie file is fully loaded, the videoDiv.buffered.end(0)
also gives correct values in both browsers.
How to use it (only 2 steps): 1) Click on any video so that it starts playing 2) Use any of the following Keyboard Controls to make the video seek forward or backward: Keyboard Controls (windows / linux): Ctrl + LeftArrow: Seek backwards 3 seconds Ctrl + RightArrow: Seek forward 3 seconds Ctrl + SpaceBar: Toggle play / ...
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.
HTML5 is now compatible with all popular browsers (Chrome, Firefox, Safari, IE9, and Opera) and with the introduction of DOCTYPE, it is even possible to have a few HTML features in older versions of Internet Explorer too.
So to get the currentTime parameter of html5 video to be working in Chrome, you need a server that supports http code 206. For anyone else having this problem, you can double check your server config with curl: This should return code 206.
Make an API call for you video, then load the blob into URL.createObjectURL and feed that into the src attribute of your video html tag. This will load the entire file and then chrome will know the size of the file allowing seeking capabilities to work.
The mp4 file is ok, by testing it on a local html file with the <video> tag all is ok (even with chrome) Is someone using this extension fine with Chrome ? Solved! Go to Solution. Jan 10, 2020 12:14 PM OK. So nothing wrong with the extension.
As a result chrome is sending requests for content that doesn't get answered which in turn makes our video's and audio unseekable (and unloopable). Show activity on this post.
It took me a while to figure it out...
The problem turned out to be server-side. I was using a version of Jetty to serve all my video-files. The simple configuration of Jetty did not support byte serving.
The difference between Firefox and Chrome is that Firefox will download the entire video file so that you can seek through it, even if the server does not support http code 206 (partial content). Chrome on the other hand refuses to download the entire file (unless it is really small, like around 2-3mb).
So to get the currentTime
parameter of html5 video to be working in Chrome, you need a server that supports http code 206.
For anyone else having this problem, you can double check your server config with curl:
curl -H Range:bytes=16- -I http://localhost:8080/GOPR0001.mp4
This should return code 206. If it returns code 200, Chrome will not be able to seek the video, but Firefox will, due to a workaround in the browser.
And a final tip: You can use npm http-server to get a simple http-server for a local folder that supports partial content:
npm install http-server -g
And run it to serve a local folder:
http-server -p 8000
If you wait for canplaythrough
instead of loadeddata
, it works.
See this codepen example.
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