Monday, May 20, 2024
144
rated 0 times [  145] [ 1]  / answers: 1 / hits: 18321  / 10 Years ago, tue, august 5, 2014, 12:00:00

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.



Stop



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.


More From » google-chrome

 Answers
19

I solved this issue by assigning an EventHandler on the videoTrack's onended property:



  // 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.


[#69904] Sunday, August 3, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ashelye

Total Points: 479
Total Questions: 97
Total Answers: 85

Location: Benin
Member since Fri, Mar 24, 2023
1 Year ago
;