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 tried using the onended
EventHandler of the MediaStream, but the MediaStream's ended
property is still set to true
after clicking on the button.
The only difference I could find between the stream (before and after clicking the button) is that the videoTracks.readyState
is set to ended
.
Edit: I would also like to notice if the user closes the window they were streaming before.