# WebRTC example - how to release the webcam?

**URL:** <https://community.wowza.com/t/webrtc-example-how-to-release-the-webcam/92396>\
**Category:** Getting Started\
**Created:** [November 24, 2020, 6:07am UTC](https://community.wowza.com/t/webrtc-example-how-to-release-the-webcam/92396 "2020-11-24T06:07:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Nottingham](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@Jason\_Nottingham](https://community.wowza.com/u/Jason_Nottingham)\
**Post date:** [November 24, 2020, 6:07am UTC](https://community.wowza.com/t/webrtc-example-how-to-release-the-webcam/92396/1 "2020-11-24T06:07:25Z")

</div>

Hi - your example at

> **[WebRTC Publishing Test for Wowza Streaming Engine](https://www.wowza.com/developer/webrtc/dev-view-publish)**
>
> As a Wowza Streaming Engine customer, you can now test WebRTC streams published from your browser. Use this page to test different configurations.

and

> **[GitHub - WowzaMediaSystems/webrtc-examples: WebRTC Examples](https://github.com/WowzaMediaSystems/webrtc-examples)**
>
> WebRTC Examples

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?

---

<div class="post-metadata">

**Author:** ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)\
**Post date:** [November 24, 2020, 6:01pm UTC](https://community.wowza.com/t/webrtc-example-how-to-release-the-webcam/92396/2 "2020-11-24T18:01:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jay\_Charles1](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/jay_charles1/32/514_2.png) [@Jay\_Charles1](https://community.wowza.com/u/Jay_Charles1)\
**Post date:** [November 25, 2020, 6:29pm UTC](https://community.wowza.com/t/webrtc-example-how-to-release-the-webcam/92396/3 "2020-11-25T18:29:29Z")

</div>

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) {  
track.stop();  
});

---

<div class="post-metadata">

**Author:** ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)\
**Post date:** [November 25, 2020, 6:43pm UTC](https://community.wowza.com/t/webrtc-example-how-to-release-the-webcam/92396/4 "2020-11-25T18:43:32Z")

</div>

Awesome, thanks so much @Jay_Charles1

---

<div class="post-metadata">

**Author:** ![Jason\_Nottingham](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@Jason\_Nottingham](https://community.wowza.com/u/Jason_Nottingham)\
**Post date:** [December 4, 2020, 5:12am UTC](https://community.wowza.com/t/webrtc-example-how-to-release-the-webcam/92396/5 "2020-12-04T05:12:35Z")

</div>

@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.

unrelated: [https://github.com/WowzaMediaSystems/webrtc-examples/blob/master/src/jquery-example/lib/WowzaWebRTCPlay.js](https://github.com/WowzaMediaSystems/webrtc-examples/blob/master/src/jquery-example/lib/WowzaWebRTCPlay.js)

line 149: let newError = {…error}

newError is never used.

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

---

<div class="post-metadata">

**Author:** ![Jason\_Nottingham](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@Jason\_Nottingham](https://community.wowza.com/u/Jason_Nottingham)\
**Post date:** [December 7, 2020, 2:47am UTC](https://community.wowza.com/t/webrtc-example-how-to-release-the-webcam/92396/6 "2020-12-07T02:47:36Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![chris\_mirador](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/chris_mirador/32/671_2.png) [@chris\_mirador](https://community.wowza.com/u/chris_mirador)\
**Post date:** [February 26, 2021, 5:39am UTC](https://community.wowza.com/t/webrtc-example-how-to-release-the-webcam/92396/7 "2021-02-26T05:39:58Z")

</div>

can you share please? TIA
