I\'m currently writing a chrome extension which uses Chrome\'s DesktopCapture API. I\'m struggling to set a callback when someone clicks on \"Stop sharing\".
I solved this issue by assigning an EventHandler on the videoTrack's onended property:
onended
// somebody clicked on "Stop sharing" stream.getVideoTracks()[0].onended = function () { // doWhatYouNeedToDo(); };
As far as my edit goes (noticing a closing window): it also fires the event.