Wowza Community

WebRTC example - how to release the webcam?

Hi - your example at


defaults to accessing the default webcam, and allows the user to switch to another, and publish it, and then stop publishing it.

What is the recommended way of RELEASING the webcam / turning it off (using the javascript on the GitHub) so that the webcam is released and the physical light/led turns off?

Hi @Jason_Nottingham, our current webrtc examples don’t support releasing the internal webcam, but it’s not impossible. It would just require some custom code.

I would suggest opening a ticket with tech support to discuss your options.

You just need to stop the MediaStreamTrack associated with the device. Your call to getUserMedia will return a MediaStream which contains one or more MediaStreamTrack instances (typically two if you requested both audio and video).

To stop the device, you’ll iterate over the tracks and stop each of them. This example assumes you’ve kept reference to the MediaStream in a variable named “ms”

ms.getTracks().forEach(function(track) {

Awesome, thanks so much @Jay_Charles1

@Jay_Charles1 thanks!

That turns off the webcam LED but there are two issues remaining, that might be related:

  • the browser tab (in Chrome/Edge/Firefox) show a red dot indicating the cam/mic is still in-use/broadcasting).

  • attempt to re-acquire the webcam fails

Would like to be able to completely release the webcam so that the red dot in the browser tab goes away, and the webcam can be re-acquired when the user wants to, without refreshing the page.


line 149: let newError = {…error}

newError is never used.

I assume line 152should be using ‘newError’ instead of ‘error’.

I have figured out the remaining steps for releasing the webcam. There are other issues with requiring the webcam and broadcasting (for longer 5 seconds) but that is probably outside the scope of the example. Thanks,

can you share please? TIA