Possible to stop webcam after using createCapture?

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

1 Like

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

  1. p5js.org/reference/#/p5/createCapture
  2. p5js.org/reference/#/p5.MediaElement
  3. p5js.org/reference/#/p5.Element

Among its many methods, we can find p5.MediaElement::pause():pause_button: & p5.MediaElement::stop() :stop_sign::

  1. p5js.org/reference/#/p5.MediaElement/pause
  2. p5js.org/reference/#/p5.MediaElement/stop
1 Like

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?

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

According to the reference the underlying code is getUserMedia.

Security note: A new browser security specification requires that getUserMedia, which is behind createCapture(),

So these might be helpful (untested):

1 Like