Is there a way to stop my webcam from recording after I’ve started it using capture = createCapture?
p5::createCapture() returns a p5.MediaElement type object, which is a more specialized subclass of its parent class p5.Element:
- p5js.org/reference/#/p5/createCapture
- p5js.org/reference/#/p5.MediaElement
- p5js.org/reference/#/p5.Element
Among its many methods, we can find p5.MediaElement::pause() & p5.MediaElement::stop() :
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.
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):