通过actionscript关闭网络摄像头使用 [英] Close webcam usage via actionscript

查看:204
本文介绍了通过actionscript关闭网络摄像头使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有办法,如何关闭webcam连接在actionscript。我通过Camera.getCamera()打开流。问题是,在释放网络摄像头实例(我试过很多方式)LIGHT在网络摄像头仍然是光束(试图在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).

推荐答案

p>您可以简单地调用 video.attachCamera(null)来释放相机。

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;
        }
    }
}

这篇关于通过actionscript关闭网络摄像头使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆