JS currentTime for html video tag not working on chrome

I want to capture the current runtime of an HTML5 video when I click on a specific button. Here is my code

var vid = document.getElementById("video1"); $('#cap-cue').click(function(){ var curtime = vid.currentTime; alert(curtime); }); 

This works great for most browsers, but doesn't work on chrome.

+5
source share
3 answers

Make sure the video element on the document is ready:

 $(function() { var vid = document.getElementById("vid"); }); $('#getTime').on('click', function() { var currentTime = vid.currentTime; $('#currentTime').html(currentTime); }); 

Jsfiddle demo

Tested on Windows using Chrome, Firefox and IE10.

+1
source

UPDATE, 10/7/15: I found that this is actually not using Chrome at the current time, but instead of processing video.load ().

Here is the error report. He is now over 2.5 years old, and he has more and more other reports, but this is a well-known mistake. If they have not fixed it at this point, then I'm not sure that he is high on the list of priorities.

This bug was combined with issue # 31014, which was flagged as fixed in August 15th, but it seems people (including me) still have the problem.

It seems that from this fact that if you try to make multiple requests to the same URL in order to recover any media item (audio or video), the network connection seems to freeze in Chrome. I checked this and, of course, exactly what happened in my case.

People have reported several workarounds in this thread above, but I could not get them to work.


currentTime does not work correctly in Chrome. I tested this with videojs today, as it was the only browser throwing a problem, then switched to the standard HTML5 video player and ran into the same problem.

Works great in FF and Edge, but doesn't work in Chrome.

Even stranger, it doesn’t produce errors without even downloading the video. At least with the help of videojs it gives an error that it cannot load.

I filed a bug report with videojs today as it was related to my player, but after a closer look, it seems to be a Chrome problem. Wish it at least throw an error for the standard HTML5 player.

+3
source

The problem (at least with regards to Chrome) is probably server side. Put the Header set Accept-Ranges bytes in your .htaccess (this is this answer )

0
source

Source: https://habr.com/ru/post/1211162/


All Articles