14

I'm using the recorder.js and getUserMedia to do some audio recording in the browser. When starting the recording, the user is given the "Allow this site to use your microphone" prompt, and once they click allow, Chrome adds an indicator onto the tab's favicon to show that it is recording:

Recording indicator
(source: ubuntuone.com)

My issue is that the indicator never goes away, even after my application has stopped recording. Basically, I'd like to revoke my own recording permissions. Is this possible?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
nickf
  • 537,072
  • 198
  • 649
  • 721

1 Answers1

12

When you generate a new MediaStream object from a getUserMedia call, it contains a MediaStreamTrack object.

Calling MediaStream.getAudioTracks() should return a sequence that represents a snapshot of all the MediaStreamTrack objects in the stream with the kind "audio". Same thing applies when calling MediaStream.getVideoTracks() to retrieve video track objects.

According to the spec, it looks like you can revoke all given permissions to your app by calling MediaStreamTrack.stop() on the audio track object.

Source: Media Capture and Stream API spec

mattfieldy
  • 146
  • 1
  • 4
  • Awesome, thanks! It also seems like just calling `mediaStream.stop()` works, without getting the tracks. – nickf Jul 22 '13 at 09:38
  • Interestingly, though this removes the indicator from the favicon, the recording can actually continue... – nickf Jul 22 '13 at 18:50
  • firefox on mac and firefox on windows work different.. mediaStream.stop() - worked for windows mediaStream.getAudioTracks()[0].stop() - worked for MacOS and ChromeOS – zeah Dec 15 '16 at 03:07
  • Since it continues to record, how would I display the indicator again when the user clicks the "Record" button? – jpenna Dec 08 '17 at 03:24