今天web部门要用fms做音视频项目,他们那儿没有flash开发的,于是老大把我调过去了,好久没用过fms(以前的fcs),研究了一下,播放做了个录制视频的咚咚,代码如下:
stop();
//connection
nc = new NetConnection();
nc.onStatus = function(info)
{
trace("Level: "+info.level+" Code: "+info.code);
};
nc.connect("rtmp://10.218.12.79/flv", _root.publishInfo);
//record video
publish_video.attachVideo(Camera.get());
nsOut = new NetStream(nc);
nsOut.attachVideo(Camera.get());
nsOut.publish(_root.publishInfo, "record");
//play video
play_ns = new NetStream(nc);
play_ns.play(_root.playInfo);
play_video.attachVideo(play_ns);
//stop video
function closeFLV()
{
play_ns.close();
play_video.clear();
play_label.text = "";
}
//stop Record
function closeRecord()
{
nsOut.close();
publish_video.clear();
publish_video.attachVideo(false);
publish_label.text = "";
}
还有点提醒大家,如果测试时只有本机可以发布flv而其他客户端不行的话,把本机的防火墙关闭,千万别跟我一样犯这种错误:)