Search code examples
google-chromegoogle-chrome-extensiongoogle-castchromecast

Chromecast event for device disconnect (sender)


Is there event that will notify a sender app when the use selects "stop cast" from within the chrome extension?

I've a chrome sender app get's in a limbo state if the user chooses to stop the cast from the extension instead of the app cast button.

EDIT: This is some relevant code:

CastPlayer.prototype.onMediaDiscovered = function (how, mediaSession) {
  this.currentMediaSession = mediaSession;
  // ...    
  this.currentMediaSession.addUpdateListener(this.onMediaStatusUpdate.bind(this));
  // ...
};

CastPlayer.prototype.onMediaStatusUpdate = function (e) {
  console.log(e);
};

Solution

  • Have you tried Session.addUpdateListener(listener) ? I think the listener will be notified when the session is no longer alive.