如何收听“停止分享”点击Chrome DesktopCapture API [英] How to listen for "Stop sharing" click in Chrome DesktopCapture API
问题描述
我目前正在编写一个Chrome扩展程序,它使用的MediaStream,但MediaStream的结束$点击按钮后,c $ c>属性仍然设置为
true
。
唯一的区别是我可以找到流之间(单击按钮之前和之后)是 videoTracks.readyState
设置为结束
。 p>
编辑:
我还想注意用户是否关闭了之前流式传输的窗口。
我通过在 videoTrack's onended
属性上分配EventHandler来解决此问题:
//有人点击编辑停止共享
stream.getVideoTracks()[0] .onended = function(){
// doWhatYouNeedToDo();
};
就我的编辑而言(注意到一个关闭窗口):它也触发事件。 p>
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.
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.
这篇关于如何收听“停止分享”点击Chrome DesktopCapture API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!