MediaRecorder.stop() doesn't clear the recording icon in the tab

后端 未结 1 1289
借酒劲吻你
借酒劲吻你 2020-12-11 01:13

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.

The icon looks like this:

1条回答
  •  隐瞒了意图╮
    2020-12-11 02:15

    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.

    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
    

    Fiddle since stacksnippets doesn't allow gUM even with https...

    And an other fiddle where the stream is accessed through MediaRecorder.stream.

    0 讨论(0)
提交回复
热议问题