3

I am currently working with webRTC and therefore use the getUserMedia() function. When doing this a red icon appears inside the tab-header. Is there a way to remove this symbol? I set my microphone stream to undefined after a certain task, but the symbol is still shown there.

kenzie
  • 217
  • 1
  • 2
  • 12

1 Answers1

6

You have to stop the MediaStream (MediaStreamTracks) you've acquired with getUserMedia

stream.getTracks().forEach(track => track.stop());
stream.stop(); // deprecated in FFox 
wpp
  • 7,093
  • 4
  • 33
  • 65
  • Thanks for that :) Is there a way to start the track afterwards again? – kenzie Mar 14 '17 at 14:42
  • Nope, you'd need to acquire a new stream. https://developer.mozilla.org/de/docs/Web/API/MediaStreamTrack – wpp Mar 14 '17 at 14:52
  • What if stream was started by third party and i did not call getUserMedia to initilize the stream then in this case how do i get the reference of created stream object and how to stop it? – Umer Ali Apr 19 '20 at 10:32
  • That really depends on the third party library and how they manage the stream object. If it is open source I'd suggest looking into the source code, otherwise their documentation. Or you can try and get some information about the environment through the browser's debugger. – wpp Apr 20 '20 at 07:15