我遇到了闪存问题,我不太熟悉。我将这段代码基于视频聊天示例中 wowza 媒体服务器附带的代码,但与该示例不同,flash 不会提示我是否允许使用摄像机。
以下是我的动作脚本:
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);
}
}
我相当有信心这很简单。正如我在讨论如何发布到实时服务器时在无数网站上看到的那样。
任何帮助将不胜感激,我尝试在网络服务器上使用此代码来查看它是否只是本地安全设置,但事实并非如此。
在 Flash CS5 中调试应用程序时收到的日志:
尝试使用 URL D:\development\qanda\qandaHost.swf
[SWF] D:\development\qanda\qandaHost.swf 启动并连接到 Player - 解压后 3583 字节
摄像头静音
nc: NetConnection.Connect.Success (连接成功。 )
nsPublish:NetStream.Publish.Start(发布测试。)