我遇到了Flash問題,我並不十分熟悉。我將這段代碼從視頻聊天示例中的wowza媒體服務器附帶的代碼中提取出來,但與此例不同,flash不會提示我是否允許攝像機。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);
}
}
我相當確信它的東西簡單;正如我在討論如何發佈到實時服務器時在無數網站上看到過的代碼一樣。
任何幫助將不勝感激,我試圖在web服務器上使用此代碼,看看它是否只是本地安全設置,但事實並非如此。
日誌調試在Flash CS5中的應用程序時,我得到:
試圖啓動並使用URL d連接到播放器:\研發\ qanda \ qandaHost.swf
[SWF] d:\研發\ qanda \ qandaHost.swf - 3583字節解壓後
相機靜音
NC:
值爲NetConnection.Connect.Success nsPublish:NetStream.Publish.Start
嗯,我已經能夠獲取連接和運行,但是我沒有看到網絡攝像頭在輸出的swf中輸入。這只是一個白色的屏幕。但是,如果我轉移到實時視頻流媒體服務器,我實際上可以看到網絡攝像頭信息。我的界面有些問題。 – Scott 2010-07-06 15:40:40