as连接FMS服务器报错状态汇总~~

nc = new NetConnection();
nc.connect("rtmp://"+_root.host+"/"+_root.dir);
//建立一个新数据流并连接到服务器
//---------------------------显示连接状态---------------------------//
nc.onStatus = function(info) {
if (info.code == "NetConnection.Call.Failed") {
   trace("连接状态: "+info.code);
   trace("NetConnection.call方法调用服务器端的方法或命令失败");
} else if (info.code == "NetConnection.Connect.AppShutdown") {
   trace("连接状态: "+info.code);
   trace("服务器端应用程序已经关闭(由于资源耗用过大等原因)或者服务器已经关闭");
} else if (info.code == "NetConnection.Connect.Closed") {
   trace("连接状态: "+info.code);
   trace("连接中断");
} else if (info.code == "NetConnection.Connect.Failed") {
   trace("连接状态: "+info.code);
   trace("连接失败");
} else if (info.code == "NetConnection.Connect.InvalidApp") {
   trace("连接状态: "+info.code);
   trace("指定的应用程序名称没有找到");
} else if (info.code == "NetConnection.Connect.Rejected") {
   trace("连接状态: "+info.code);
   trace("连接被拒绝");
} else if (info.code == "NetConnection.Connect.Success") {
   trace("连接状态: "+info.code);
   trace("连接成功");
}
};

//---------------------------与服务器通讯---------------------------//
var returnTimeObj = new Object();
var serverTim:Number;
returnTimeObj.onResult = function(tim):Void   {
trace("请求的结果是影片时长:"+tim+" 秒");
serverTim = tim;
      //将函数内部变量赋值给局部变量以便以后引用
//如果返回时间为0表示此数据流为直播流
};
//client向server提交文件请求
nc.call("getStreamLength",returnTimeObj,_root.url);
trace("客户端主正在向服务器提交对"+_root.url+".flv文件的请求");

//server呼叫client端
nc.msgFromServer = function(msg) {
trace("服务端发来信息:"+msg);
};

//---------------------------播放器部分---------------------------//

in_ns = new NetStream(nc);
_parent.mv_video.video_container.attachVideo(in_ns);
//videoArea.attachAudio(in_ns);
in_ns.setBufferTime(5);//定义缓冲时间(单位:秒)
in_ns.play(_root.url);//开始播放

//---------------------------sink color---------------------------//

var btnDefaultColor:String = "0x6D6D6D";
var btnActColor:String = "0x4EB4FF";
var barDefaultColor:String = "0xFFFFFF";
var barActColor:String = "0x4EB4FF";
//这里定义了按扭的颜色可自行修改

//---------------------------pause---------------------------//

btn_pauseColor = new Color(btn_pause.btn_light01);
btn_pause.onRollOver = function() {
btn_pauseColor.setRGB(btnActColor);
};
btn_pause.onRollOut = function() {
btn_pauseColor.setRGB(btnDefaultColor);
};
btn_pause.onRelease = function() {
btn_pauseColor.setRGB(btnDefaultColor);
in_ns.pause();
};
btn_pause.onReleaseOutside = btn_pause.onRelease;

//---------------------------stop---------------------------//
btn_stopColor = new Color(btn_stop.btn_light01);
btn_stop.onRollOver = function() {
btn_stopColor.setRGB(btnActColor);
};
btn_stop.onRollOut = function() {
btn_stopColor.setRGB(btnDefaultColor);
};
btn_stop.onRelease = function() {
btn_stopColor.setRGB(btnDefaultColor);
in_ns.seek(0);
in_ns.pause(true);//跳转起始时间并暂停
};
btn_stop.onReleaseOutside = btn_stop.onRelease;

//---------------------------repetition---------------------------//

var switchRepetition:Boolean = true;
//定义为默认情况下循环播放
btn_repetitionColor = new Color(btn_repetition.btn_light01);
btn_repetition.onRollOver = function() {
btn_repetitionColor.setRGB(btnActColor);
};
btn_repetition.onRollOut = function() {
btn_repetitionColor.setRGB(btnDefaultColor);
};
btn_repetition.onRelease = function() {
btn_repetitionColor.setRGB(btnDefaultColor);
if (switchRepetition == true) {
   switchRepetition = false;
   btn_repetition.shape_repetition.gotoAndStop(btn_repetition.shape_repetition._totalframes);
} else {
   switchRepetition = true;
   btn_repetition.shape_repetition.gotoAndPlay(btn_repetition.shape_repetition._currentframe+1);
}
};

btn_repetition.onReleaseOutside = btn_repetition.onRelease;
in_ns.onPlayStatus = function(info) {
if (info.code == "NetStream.Play.Complete") {
   //检查影片是否播放完毕
   if (switchRepetition == true) {
      in_ns.seek(0);
      in_ns.play();//如果需要循环播放便跳转起始时间并播放
   } else {
      in_ns.seek(0);
      in_ns.pause(true);//否则跳转起始时间并暂停(注意默认情况下是循环的)
   }
}
};

//---------------------------fullscreen---------------------------//

btn_fullscreenColor = new Color(btn_fullscreen.btn_light01);
btn_fullscreen.onRollOver = function() {
btn_fullscreenColor.setRGB(btnActColor);
};
btn_fullscreen.onRollOut = function() {
btn_fullscreenColor.setRGB(btnDefaultColor);
};
btn_fullscreen.onRelease = function() {
btn_fullscreenColor.setRGB(btnDefaultColor);
//启动全屏(这里我没写全屏函数到底是用JS方法还是用FLASH内部函数办法根据需要你们自己看着办吧)
};
btn_fullscreen.onReleaseOutside = btn_fullscreen.onRelease;

//---------------------------help---------------------------//

btn_helpColor = new Color(btn_help.btn_light01);
btn_help.onRollOver = function() {
btn_helpColor.setRGB(btnActColor);
};
btn_help.onRollOut = function() {
btn_helpColor.setRGB(btnDefaultColor);
};
btn_help.onRelease = function() {
btn_helpColor.setRGB(btnDefaultColor);
//弹出播放帮助页(要弹什么版权页或者说明页你们自己看着办或者你也可以播放你自己做的MC)
};
btn_help.onReleaseOutside = btn_help.onRelease;

 

//---------------------------容错判断---------------------------//

in_ns.onStatus = function(info) {
if (info.code == "NetStream.Buffer.Full") {
   trace("播放状态: "+info.code);
   trace("缓冲区已满");
   btn_pause.shape_play._visible = true;
   btn_pause.shape_pause._visible = false;
} else if (info.code == "NetStream.Buffer.Empty") {
   trace("播放状态: "+info.code);
   trace("数据缓冲区为空");
   btn_pause.shape_play._visible = false;
   btn_pause.shape_pause._visible = true;
} else if (info.code == "NetStream.Failed") {
   trace("播放状态: "+info.code);
   trace("传输中有错误发生");
   //无需反馈
} else if (info.code == "NetStream.Pause.Notify") {
   trace("播放状态: "+info.code);
   trace("播放暂停");
   btn_pause.shape_play._visible = false;
   btn_pause.shape_pause._visible = true;
} else if (info.code == "NetStream.Play.Failed") {
   trace("播放状态: "+info.code);
   trace("播放出错");
   //严重错误
} else if (info.code == "NetStream.Play.PublishNotify") {
   trace("播放状态: "+info.code);
   trace("发布开始,信息已经发送到所有订阅者");
   //无需反馈
} else if (info.code == "NetStream.Play.Reset") {
   trace("播放状态: "+info.code);
   trace("播放列表重置");
   //无需反馈
} else if (info.code == "NetStream.Play.Start") {
   trace("播放状态: "+info.code);
   trace("播放开始");
   btn_pause.shape_play._visible = false;
   btn_pause.shape_pause._visible = true;
} else if (info.code == "NetStream.Play.Stop") {
   trace("播放状态: "+info.code);
   trace("播放停止");
   //无需反馈
} else if (info.code == "NetStream.Play.StreamNotFound") {
   trace("播放状态: "+info.code);
   trace("播放的实时流或文件不存在");
   //严重错误
} else if (info.code == "NetStream.Play.UnpublishNotify") {
   trace("播放状态: "+info.code);
   trace("发布停止,信息已经发送到所有订阅者");
   //无需反馈
} else if (info.code == "NetStream.Publish.BadName") {
   trace("播放状态: "+info.code);
   trace("发布的数据流已经被发布");
   //无需反馈
} else if (info.code == "NetStream.Publish.Idle") {
   trace("播放状态: "+info.code);
   trace("发布者闲置过长");
   //严重错误
} else if (info.code == "NetStream.Publish.Start") {
   trace("播放状态: "+info.code);
   trace("发布开始");
   btn_pause.shape_play._visible = false;
   btn_pause.shape_pause._visible = true;
} else if (info.code == "NetStream.Record.Failed") {
   trace("播放状态: "+info.code);
   trace("录制文件出错");
   //严重错误
} else if (info.code == "NetStream.Record.NoAccess") {
   trace("播放状态: "+info.code);
   trace("没有足够的文件访问权限");
   //严重错误
} else if (info.code == "NetStream.Record.Start") {
   trace("播放状态: "+info.code);
   trace("文件录制开始");
   //无需反馈
} else if (info.code == "NetStream.Record.Stop") {
   trace("播放状态: "+info.code);
   trace("录制暂停");
   //无需反馈
} else if (info.code == "NetStream.Seek.Failed") {
   trace("播放状态: "+info.code);
   trace("数据流定位出错");
   //严重错误
} else if (info.code == "NetStream.Seek.Notify") {
   trace("播放状态: "+info.code);
   trace("数据搜索定位成功");
   btn_pause.shape_play._visible = false;
   btn_pause.shape_pause._visible = true;
} else if (info.code == "NetStream.Unpause.Notify") {
   trace("播放状态: "+info.code);
   trace("恢复播放");
   btn_pause.shape_play._visible = false;
   btn_pause.shape_pause._visible = true;
} else if (info.code == "NetStream.Unpublish.Success") {
   trace("播放状态: "+info.code);
   trace("停止发布");
   //无需反馈
}
};

//---------------------------time progress bar---------------------------//

time_barColor = new Color(btn_time.time_bar);
var timeProgressAct:Boolean = false;
var inTim:Number;
var barLeft = btn_time.time_progress._x;
var barRight = btn_time.time_progress._x+btn_time.time_progress._width-btn_time.time_bar._width;
var barBottom = barTop=btn_time.time_bar._y;
//确定slider可移动的左右及上下边界

btn_time.time_bar.onRollOver = function() {
time_barColor.setRGB(barActColor);
};

btn_time.time_bar.onRollOut = function() {
time_barColor.setRGB(barDefaultColor);
};

btn_time.time_bar.onPress = function() {
time_barColor.setRGB(barActColor);
this.startDrag(false,barLeft,barTop,barRight,barBottom);
timeProgressAct = true;
};

btn_time.time_bar.onRelease = function() {
time_barColor.setRGB(barDefaultColor);
this.stopDrag();
inTim = btn_time.time_bar._x*serverTim/(barRight-barLeft);
trace(serverTim);
in_ns.seek(inTim);
in_ns.play();//计算并且跳转到和滑块位置对应的播放时间
timeProgressAct = false;
//trace("目前移动到"+btn_time.time_bar._x+"位置");
//trace("影片时长"+tim);
//trace("inTime="+inTim);
//trace("in_ns.time="+in_ns.time);
};

btn_time.time_bar.onReleaseOutside = btn_time.time_bar.onRelease;

//---------------------------time container---------------------------//

function convertTime(sec, role) {
      //定义格式化时间用的函数并且根据role的需要输出不同的数据
var sec:Number;
var role:String;
sec = Math.floor(sec);
var day = (Math.floor(sec/3600/24)<10) ? "0"+Math.floor(sec/3600/24) : Math.floor(sec/3600/24);
var hour = (Math.floor(sec%(3600*24)/3600)<10) ? "0"+Math.floor(sec%(3600*24)/3600) : Math.floor(sec%(3600*24)/3600);
var minute = (Math.floor(sec%3600/60)<10) ? "0"+Math.floor(sec%3600/60) : Math.floor(sec%3600/60);
var second = (sec%60<10) ? "0"+sec%60 : sec%60;
if ((day>0) || (hour>0) || (minute>0) || (second>0)) {
   return hour+":"+minute+":"+second;
} else if (role != "server") {
   return "00:00:00";
} else if (role="server") {
   return "Live";
}
}

onEnterFrame = function () {
btn_time.time_container.time_text = convertTime(in_ns.time, "client")+"/x20"+"/"+"/x20"+convertTime(serverTim, "server");
if (timeProgressAct == false) {
   btn_time.time_bar._x = in_ns.time/serverTim*(barRight-barLeft);
}
if ((in_ns.bufferLength>0) && (in_ns.bufferTime>=in_ns.bufferLength) && (btn_pause.shape_pause._visible == true)) {
   //trace("已经缓冲"+in_ns.bufferLength+"秒");
   //播放缓冲动画(自己搞个带LOGO的版权动画出来吧我已经把我们公司的去掉了)
} else {
   //trace("已经缓冲"+in_ns.bufferLength+"秒");
   //隐藏缓冲动画
}
};

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值