# Possible to stop webcam after using createCapture?

**URL:** <https://discourse.processing.org/t/possible-to-stop-webcam-after-using-createcapture/10557>\
**Category:** Coding Questions\
**Created:** [April 23, 2019, 6:05am UTC](https://discourse.processing.org/t/possible-to-stop-webcam-after-using-createcapture/10557 "2019-04-23T06:05:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![computershawn](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@computershawn](https://discourse.processing.org/u/computershawn)\
**Post date:** [April 23, 2019, 6:05am UTC](https://discourse.processing.org/t/possible-to-stop-webcam-after-using-createcapture/10557/1 "2019-04-23T06:05:44Z")

</div>

Is there a way to stop my webcam from recording after I’ve started it using _capture = createCapture_?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 23, 2019, 6:50am UTC](https://discourse.processing.org/t/possible-to-stop-webcam-after-using-createcapture/10557/2 "2019-04-23T06:50:44Z")

</div>

p5::**createCapture()** returns a p5.MediaElement type object, which is a more specialized subclass of its parent class p5.Element: 📽

1. [p5js.org/reference/#/p5/createCapture](http://p5js.org/reference/#/p5/createCapture)
2. [p5js.org/reference/#/p5.MediaElement](http://p5js.org/reference/#/p5.MediaElement)
3. [p5js.org/reference/#/p5.Element](http://p5js.org/reference/#/p5.Element)

Among its many methods, we can find p5.MediaElement::**pause()**⏸ & p5.MediaElement::**stop()** 🛑:

1. [p5js.org/reference/#/p5.MediaElement/pause](http://p5js.org/reference/#/p5.MediaElement/pause)
2. [p5js.org/reference/#/p5.MediaElement/stop](http://p5js.org/reference/#/p5.MediaElement/stop)

---

<div class="post-metadata">

**Author:** ![computershawn](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@computershawn](https://discourse.processing.org/u/computershawn)\
**Post date:** [April 24, 2019, 6:33am UTC](https://discourse.processing.org/t/possible-to-stop-webcam-after-using-createcapture/10557/3 "2019-04-24T06:33:05Z")

</div>

Hey GoToLoop, thanks for your reply. I see that running the stop() function stops the camera from recording while letting the sketch continue looping. But in the case of my Macbook Pro, the webcam LED stays on after running stop(). If my webcam’s video capture has stopped, shouldn’t the LED turn off?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [April 24, 2019, 6:51am UTC](https://discourse.processing.org/t/possible-to-stop-webcam-after-using-createcapture/10557/4 "2019-04-24T06:51:15Z")

</div>

Sorry, but I don’t have a Mac nor even have used **createCapture()** yet. 😑

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [April 28, 2019, 7:08am UTC](https://discourse.processing.org/t/possible-to-stop-webcam-after-using-createcapture/10557/5 "2019-04-28T07:08:09Z")

</div>

According to the reference the underlying code is getUserMedia.

> Security note: A new browser security specification requires that getUserMedia, which is behind [createCapture()](https://p5js.org/reference/#/p5/createCapture),

So these might be helpful (untested):

> <https://stackoverflow.com/questions/28140147/turn-off-webcam-camera-after-using-getusermedia>

> <https://stackoverflow.com/questions/11642926/stop-close-webcam-stream-which-is-opened-by-navigator-mediadevices-getusermedia>
