videojs-youtube icon indicating copy to clipboard operation
videojs-youtube copied to clipboard

unstarted state events fired twice

Open dbettini opened this issue 7 years ago • 3 comments

As per youtube iframe API documentation: "When the player first loads a video, it will broadcast an unstarted (-1) event. When a video is cued and ready to play, the player will broadcast a video cued (5) event." In videojs-youtube code, 4 events (loadstart, loadedmetadata, durationchange, ratechange) are fired each time state changes to unstarted. However, for some reason, when starting the video, it moves from cued (5) to unstarted (-1) again before moving to buffering (3) and then playing (1). That means these events will always be fired twice - first time before the video moves to cued state, and second when you start the video. Is this intended? Not sure what is the reason for the second change to unstarted before play, and if it's a youtube iframe thing, maybe the events should not be fired when moving from cued to unstarted?

P.S. Also, in the referenced line of code, case -1: line should probably be changed to case YT.PlayerState.UNSTARTED:. It's not documented in the iframe docs, but it does exist in the scope.

dbettini avatar Mar 29 '17 14:03 dbettini

I'm also hitting this issue.

vheuken avatar Apr 23 '18 23:04 vheuken

Same here :/

IvanNikolchov avatar Jun 04 '18 18:06 IvanNikolchov

Same...

zivkaziv avatar Dec 30 '19 13:12 zivkaziv