HTML5 video - setting video.currentTime rips player

I am trying to interact with a third-party html5 video player in Chrome. I can get the correct link to it:

document.getElementsByTagName("video")[1]

... and readyStateequal to 4, so everything is fine.

I can successfully (and with the expected result) call:

document.getElementsByTagName("video")[1].play();
document.getElementsByTagName("video")[1].pause();

BUT when I call:

document.getElementsByTagName("video")[1].currentTime = 500;

... the video freezes and it doesn't move on to a new one currentTime. The video is much longer than 500 seconds, so it must be able to advance to this place. I tried other times besides 500, all with the same result. If I review currentTime, it’s right that I just installed. But actually it is not. Also I can no longer interact with the video. It ignores any calls play()or pause()after I try to establish currentTime.

currentTime, play(), , : enter image description here

currentTime, <26 > , , : enter image description here

Hulu , , Chrome.

: , , . .

+4
4

, , ,

document.getElementsByTagName("video")[1].pause();
document.getElementsByTagName("video")[1].currentTime = 500;
document.getElementsByTagName("video")[1].play();
+1

.

function setTime(tValue) {
        //  if no video is loaded, this throws an exception 
            try {
                if (tValue == 0) {
                    video.currentTime = tValue;
                }
                else {
                    video.currentTime += tValue;
                }

             } catch (err) {
                 // errMessage(err) // show exception
             errMessage("Video content might not be loaded");
               }
     }
0
var myVideo=document.getElementsByTagName("video")
if(myVideo[1] != undefind)
{
    myVideo[1].currentTime=500;
}
/* or provide id to each video tag and use getElementById('id')    */
var myVideo=document.getElementById("videoId")
if(myVideo != undefind)
{
    myVideo.currentTime=500;
}
0
source

Pls. try the following:

hv = document.getElementsByTagName("video")[1];

hv.play();
hv.addEventListener('canplay', function() {
    this.currentTime = 500;
});
0
source

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


All Articles