Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cancel getUserMedia indicator after recording

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?

like image 338
nickf Avatar asked Jul 22 '13 09:07

nickf


1 Answers

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

like image 82
mattfieldy Avatar answered Sep 27 '22 20:09

mattfieldy