Actionscript 3 Flash网络摄像头权限
我对flash有点不熟悉。我是根据视频聊天示例中wowza media server附带的代码编写的,但与该示例不同,flash没有提示我是否允许使用摄像机 下面是我的动作脚本:Actionscript 3 Flash网络摄像头权限,actionscript-3,webcam,wowza,Actionscript 3,Webcam,Wowza,我对flash有点不熟悉。我是根据视频聊天示例中wowza media server附带的代码编写的,但与该示例不同,flash没有提示我是否允许使用摄像机 下面是我的动作脚本: import flash.events.MouseEvent; import flash.events.NetStatusEvent; import flash.media.Camera; import flash.media.Microphone; import flash.media.Video; import f
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);
}
}
我相当确信这是一件简单的事情;在讨论如何发布到实时服务器时,我在无数网站上看到了这段代码
任何帮助都将不胜感激,我曾尝试在Web服务器上使用此代码来查看它是否只是本地安全设置,但事实并非如此
在Flash CS5中调试应用程序时收到的日志:
正在尝试使用URL D:\development\qanda\qandaHost.swf启动并连接到播放机[SWF]D:\development\qanda\qandaHost.SWF-解压后3583字节
相机静音
nc:NetConnection.Connect.Success(连接成功)。
nsPublish:NetStream.Publish.Start(发布测试)。我没有将摄像头连接到视频,因此我看不到自己——即使视频实际上是流式的
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);
}
以下是错误的:
Security.showSettings(SecurityPanel.**CAMERA**);
你应该写:
Security.showSettings(SecurityPanel.**PRIVACY**);
嗯,我已经能够建立连接并运行了,但是我在导出的swf中没有看到网络摄像头提要。它只是一个白色的屏幕。然而,如果我移动到实时视频流服务器,我实际上可以看到网络摄像头信息。我的界面出了点问题。