通过ActionScript关闭摄像头的使用摄像头、ActionScript

2023-09-08 12:16:39 作者:◆◇sorrow °痕迹、

有没有办法,如何关闭动作的摄像头连接。我通过Camera.getCamera开流()。问题是,释放网络摄像头实例后(我尝试过很多办法)灯的摄像头依然是梁(试穿的MacBook Pro)。

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).

推荐答案

您可以简单地调用和Video.attachCamera(空)释放相机。

You can simply call video.attachCamera(null) to free the camera.

下面的例子演示了code。当您单击在舞台上,摄像机被打开/关闭。

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;
    	}
    }
}
 
精彩推荐
图片推荐