开发者

Flash Webcam Permissions

开发者 https://www.devze.com 2023-01-05 17:29 出处:网络
I\'m having an issue with flash, which I am not really familiar with.I\'m basing this code off of what came with the wowza media server in the video chat example, but unlike that example flash is not

I'm having an issue with flash, which I am not really familiar with. I'm basing this code off of what came with the wowza media server in the video chat example, but unlike that example flash is not prompting me for whether or not to allow the video camera.

Below is my act开发者_如何学运维ionscript:

import flash.events.MouseEvent;
import flash.events.NetStatusEvent;
import flash.media.Camera;
import flash.media.Microphone;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.system.Security;
import flash.system.SecurityPanel;
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.StatusEvent;

public class QandA extends Sprite {
    Security.LOCAL_TRUSTED;

    private var nc:NetConnection = null;
    private var camera:Camera;
    private var microphone:Microphone;
    private var nsPublish:NetStream = null;                      
    private var nsPlay:NetStream = null;
    private var videoCamera:Video;
    public var prompt:TextField;

    public function QandA():void {
        stage.align = "TL";
        stage.scaleMode = "noScale";
        videoCamera = new Video(160,120);
        addChild(videoCamera);
        camera = Camera.getCamera();
        microphone = Microphone.getMicrophone();
        if (camera.muted) {
            trace("Camera Muted");
            Security.showSettings(SecurityPanel.CAMERA);
            camera.addEventListener(StatusEvent.STATUS, statusHandler);
        } else {
            startCamera();
        }

    }

    private function statusHandler(e:StatusEvent):void {
        if (e.code == "Camera.Unmuted") {
            trace("Camera Unmuted");
            startCamera();
            camera.removeEventListener(StatusEvent.STATUS, statusHandler);
        } else {
            trace("StatusEvent: " + e.code + " " + e.toString());
        }
    }

    private function startCamera():void {
        // here are all the quality and performance settings that we suggest
        camera.setMode(160, 120, 12, false);
        camera.setQuality(0, 75);
        camera.setKeyFrameInterval(24);
        microphone.rate = 11;
        microphone.setSilenceLevel(0);

        nc = new NetConnection();
        nc.connect("rtmp://localhost/live/");

        // get status information from the NetConnection object
        nc.addEventListener(NetStatusEvent.NET_STATUS, ncOnStatus); 
    }

    private function nsPublishOnStatus(infoObject:NetStatusEvent):void
    {
        trace("nsPublish: "+infoObject.info.code+" ("+infoObject.info.description+")");
    }

    private function ncOnStatus(infoObject:NetStatusEvent):void
    {
        trace("nc: "+infoObject.info.code+" ("+infoObject.info.description+")");
        nsPublish = new NetStream(nc);
        nsPublish.addEventListener(NetStatusEvent.NET_STATUS, nsPublishOnStatus);
        nsPublish.bufferTime = 0;
        nsPublish.publish("testing");
        // attach the camera and microphone to the server
        nsPublish.attachCamera(camera);
        nsPublish.attachAudio(microphone);
    }
}

I'm fairly confident it's something simple; as I've seen this code in/on countless sites when discussing how to publish to a live server.

Any help would be greatly appreciated, I've attempted using this code on a webserver to see if it was simply local security settings, but that was not the case.

Logs I receive when debugging the application in Flash CS5:

Attempting to launch and connect to Player using URL D:\development\qanda\qandaHost.swf

[SWF] D:\development\qanda\qandaHost.swf - 3583 bytes after decompression

Camera Muted

nc: NetConnection.Connect.Success (Connection succeeded.)

nsPublish: NetStream.Publish.Start (Publishing testing.)


Below is wrong:

Security.showSettings(SecurityPanel.**CAMERA**);

You should write:

Security.showSettings(SecurityPanel.**PRIVACY**);


I wasn't attaching the camera to the video, thus I couldn't see myself -- even though the video was in fact streaming.

private function startCamera():void {
    trace("Attempting to start camera");
    // here are all the quality and performance settings that we suggest
    camera.setMode(160, 120, 12, false);
    camera.setQuality(0, 75);
    camera.setKeyFrameInterval(24);
    videoCamera.attachCamera(camera);
    microphone.rate = 11;
    microphone.setSilenceLevel(0);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消