How to listen for “Stop sharing” click in Chrome DesktopCapture API

后端 未结 3 1839
囚心锁ツ
囚心锁ツ 2020-12-29 07:13

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\".

3条回答
  •  我在风中等你
    2020-12-29 08:04

    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.

提交回复
热议问题