首页 > 网络安全 > 媒体动画

利用fms服务器和flex来做在线视频聊天

admin 媒体动画 2022-02-20 22:21:44 3D设计   fms   flex   在线视频聊天"
1.FMS服务器的搭建,一定要选live的,不要选vod的

2.flex的代码如下!

复制代码代码如下:
<?xml version="1.0" encoding="utf-8"?>










import flash.events.*;
private var pnc:NetConnection;
private var rnc:NetConnection;
private 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.addEventListener(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.addEventListener(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必须与发布流的流名一致
}
}
]]>




版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。
本文地址:/3Dsheji/169658.html

留言与评论(共有 0 条评论)
   
验证码:

潘少俊衡

| 桂ICP备2023010378号-4

Powered By EmpireCMS

爱享小站

中德益农

谷姐神农

环亚肥料

使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

感谢潘少俊衡友情技术支持