webcamjs icon indicating copy to clipboard operation
webcamjs copied to clipboard

Webcam turn off

Open barabaz-z-z opened this issue 9 years ago • 7 comments

Hello. If I use webcam as HTML5 element I can control stream and define whether webcam turn off. But how can I define whether webcam is turned off if I use it as flash element? Is there any event or hook?

I can subscribe to the onended event of stream. And it works good when webcam stays unavailable (unplug it from computer). Is there the same event for flash?

I tried to change your webcam.as by adding else-branch to activityHandler. But it couldn't help.

What do you think if I add timer to your actionscript which will check camera? Is it good practice?

barabaz-z-z avatar Mar 02 '15 06:03 barabaz-z-z

Hmm, I have no idea how to do this in ActionScript / Flash, but I will leave this issue open as a future feature request.

If you figure it out, feel free to submit a pull request!

jhuckaby avatar Mar 04 '15 19:03 jhuckaby

I played around a bit myself by trying to add a reset function to the action script.

public function reset() {
  trace("Turning off camera");
  video.attachCamera(null);
  video.clear();
  camera = null;
  removeChild(video);
}

I added an external callback, and called it as part of the reset of webcam.js. It seems at that point, every browser except Internet Explorer releases the camera correctly - which kind of defeats the whole purpose since every other browser does release when using getUserMedia.

Seems like there may be some issues with how Internet Explorer and Flash hold on to the camera stream, so I'm not sure if anything else could be done here.

scurker avatar May 08 '15 19:05 scurker

If you set the webcam's container element to display: none flash will turn off the webcam (probably a security feature, i'm guessing). Seems like a hacky solution, though.

positlabs avatar May 08 '15 22:05 positlabs

That seems better than nothing. I'll have to give that a try.

scurker avatar May 09 '15 05:05 scurker

This is not working.. it complains that video does not exist

amirvenus avatar Sep 07 '17 11:09 amirvenus

You have to use Webcam.reset();

dineshnagarit avatar Jan 03 '19 18:01 dineshnagarit

You have to use Webcam.reset();

THANK YOU!!!

sheinavi avatar Jul 10 '20 05:07 sheinavi