1.FMS服务器建设,一定要选择直播,不要vod。
2.2.flex的代码如下!
复制代码
代码如下:
import flash.events.*;
private var pnc:NetConnection;
private var rnc:NetConnection;
私有var PNs:NetStream;//发布流
private var rns:NetStream;
private var cam:Camera;
private var mic:Microphone;
private var video:Video;
private function onPublishClick():void
{
pnc=new NetConnection();
pnc.connect('rtmp://ip/live');
PNC。addevent侦听器(NetStatusEvent .NET_STATUS,onPublishNetStatusHandler);
cam=Camera.getCamera();
mic=Microphone.getMicrophone();
this.PublishVideo.attachCamera(cam);
}
private function onPublishNetStatusHandler(evt:NetStatusEvent):void
{
this.lbPublish.text=evt.info.code;
if(evt.info.code=='NetConnection.Connect.Success')
{
pns=new NetStream(pnc);
pns.attachAudio(mic);
pns.attachCamera(cam);
pns.client=this;
pns.publish('publishName '' live ');
}
}
private function onRecordClik():void
{
rnc=new NetConnection();
rnc.connect('rtmp://ip/live');
RNC。addevent侦听器(NetStatusEvent .NET_STATUS,onReordNetStatusHandler);
}
private function onReordNetStatusHandler(evt:NetStatusEvent):void
{
this.lbRecord.text=evt.info.code;
if(evt.info.code=='NetConnection.Connect.Success')
{
rns=new NetStream(rnc);
rns.client=this;
video=new Video();
video.width=320;
video.height=240;
video.attachNetStream(rns);
this.RecordVideo.addChild(video);
rns.play('publishName '' live ');//此处的publishName必须与发布流的流名一致。
}
}
]]