silvermine / videojs-chromecast

MIT License
147 stars 74 forks source link

Android is now sending only one Idle state event on first play #167

Open RavWar opened 10 months ago

RavWar commented 10 months ago

Hi,

Recently (about a month ago or so) chromecasting from android phone stopped working properly, video player on the phone in 90% of cases becomes stuck and is not responding to any actions or commands. After debugging i found out it's due to Chromecast sending only one single Idle event at the start of first playback, but we wait for Playing event which is not sent. Because of this triggerReady is not firing and Chromecast tech is not completely initialized. Not sure if it's the best solution, but i've added additional !this._hasPlayedAnyItem condition here:

   _onPlayerStateChanged: function() {
      var states = chrome.cast.media.PlayerState,
          playerState = this._remotePlayer.playerState;

      // On android in the begginning statechange triggers only once with status Idle and not Playing
      if (playerState === states.PLAYING || !this._hasPlayedAnyItem) {