var fmsIP:String = "127.0.0.1";
var fmsPath:String = "rtmp://"+fmsIP+"/audioOnLine_fms/";
var myNC:NetConnection = new NetConnection();
myNC.objectEncoding = ObjectEncoding.AMF0;
myNC.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
myNC.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success":
trace("连接成功!")
getStream();
break;
case "NetStream.Play.StreamNotFound":
trace("未找到视频文件: " + videoURL);
break;
}
}
function securityErrorHandler(event:SecurityErrorEvent):void {
trace("安全沙箱错误侦听: " + event);
}
function getStream():void {
var myNS:NetStream = new NetStream(myNC);
myNS.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
movie.Live_video.attachNetStream(myNS);
myNS.play("1");
}
myNC.connect(fmsPath)