Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
};
like image 852
a--m Avatar asked Jan 11 '23 03:01

a--m


2 Answers

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

like image 171
Ali Naddaf Avatar answered Jan 13 '23 16:01

Ali Naddaf


It seems Google developers are pretty aware of that! :D They've just update their senders sample code with a commit that is exactly what seems you're looking for: Added session update listener to handle disconnect by clicking cast extension

There's also another commit with the same text in another sample but with less code, here you have: https://github.com/googlecast/CastHelloVideo-chrome/commit/776559c9aaf16d7d82c62ee4dea611b6177ac217

like image 35
Angel Avatar answered Jan 13 '23 17:01

Angel