MediaRecorder.stop()不会清除选项卡中的录制图标 [英] MediaRecorder.stop() doesn't clear the recording icon in the tab
问题描述
我启动并停止MediaRecorder流。红色录制图标在开始时显示在Chrome标签中,但在停止时不会消失。
I start and stop a MediaRecorder stream. The red "recording" icon appears in the Chrome tab on start, but doesn't go away on stop.
图标如下所示:
我的代码如下所示:
const mediaRecorder = new MediaRecorder(stream);
...
// Recording icon in the tab becomes visible.
mediaRecorder.start();
...
// Recording icon is still visible.
mediaRecorder.stop();
我还有 mediaRecorder.onstop
处理程序定义。它不会返回任何内容或干扰事件对象。
I also have a mediaRecorder.onstop
handler defined. It doesn't return anything or interfere with the event object.
在启动和停止MediaRecorder实例后,清除选项卡的录制指示符的正确方法是什么?
What's the proper way to clear the "recording" indicator for a tab after starting and stopping a MediaRecorder instance?
推荐答案
这是因为此录制图标是 getUserMedia
流媒体图标之一,而不是 MediaRecorder
。
当你停止
MediaRecorder时,流仍然是活跃。
This is because this recording icon is the one of getUserMedia
streaming, not the one of MediaRecorder
.
When you stop
the MediaRecorder, the stream is still active.
要停止此gUM流(或任何其他MediaStream),您需要调用 MediaStreamTrack.stop()
。
To stop this gUM stream (or any other MediaStream), you'd call MediaStreamTrack.stop()
.
stream.getTracks() // get all tracks from the MediaStream
.forEach( track => track.stop() ); // stop each of them
小提琴 ,因为即使使用https,stacksnippets也不允许使用gUM ...
Fiddle since stacksnippets doesn't allow gUM even with https...
并且< a href =https://jsfiddle.net/8upv28ok/2/ =noreferrer>其他小提琴,通过 MediaRecorder.stream
。
这篇关于MediaRecorder.stop()不会清除选项卡中的录制图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!