Sarath
Sarath

Reputation: 9156

Play event is going to infinite loop in videojs

I just did a small example of videojs, which has a log on event play, and i am using APIs like play(),pause().

var myplayer;
var playCount = 0;
videojs("example_video_1").ready(function(){

      myplayer = this;

      myplayer.on("play", function(){
        playCount++;
        $("#count").text(playCount)

      });

});
$("#test").click(function (){  
    myplayer.pause();
    myplayer.play();
});

The issue is that while executing the APIs the play event will go to an infinite loop.

I can found this issue in touch devices if I enable the controls even while seeking the bar, do play pause etc. So if I didnt use the combination also I can found this issues. Internally the library is using these APIs in seek, or other controls ?

Link in jsfiddle LIVE BUG:

Upvotes: 2

Views: 8996

Answers (2)

Sarath
Sarath

Reputation: 9156

This is the fix forthis issue... https://github.com/cameront/video.js/commit/ff0b443c285691074f7f01e8d0326ade0f0a6609 for issues/620

Upvotes: 1

Cameron Tangney
Cameron Tangney

Reputation: 678

This is a bug in video js event handling:

https://github.com/videojs/video.js/issues/573 <-- original bug

https://github.com/videojs/video.js/issues/620 <-- best info on 'why' here

In the meantime, one workaround is to put any play/pause toggles in timeouts.

$("#test").click(function (){
    myplayer.pause();
    window.setTimeout(function() {myplayer.play();}, 10);
});

Upvotes: 3

Related Questions