Is there way, how to close webcam connection in actionscript. I am opening stream through Camera.getCamera(). Problem is, that after freeing webcam instance (i tried many ways) LIGHT on webcam is still beam (tried on macbook pro).
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can simply call video.attachCamera(null)
to free the camera.
The below example demonstrates the code. When you click on the stage, Camera is toggled on/off.
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.media.Camera;
import flash.media.Video;
public class testAS3 extends Sprite
{
public var cam:Camera;
public var video:Video;
public var camOn:Boolean = false;
public function testAS3()
{
cam = Camera.getCamera();
video = new Video();
addChild(video);
stage.addEventListener(MouseEvent.CLICK,toggleCamera);
}
public function toggleCamera(evt:Event):void {
if (camOn){
video.attachCamera(null);
} else {
video.attachCamera(cam);
}
camOn = !camOn;
}
}
}