首页 新闻 会员 周边 捐助

Flex 在线视频聊天 联网不可以

0
[已解决问题] 解决于 2013-06-11 15:43

Flex做时时视频,为什么在自己的机子上测试可以,一旦在别的机子上连接就不可以,下面是代码,大神们帮帮忙,小子感激不尽

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" height="388">
    <mx:Panel x="10" y="10" width="340" height="282" layout="absolute" title="视频发布端">
        <mx:VideoDisplay x="0" y="0" width="320" height="240" id="PublishVideo"/>
    </mx:Panel>
    <mx:Panel x="366" y="10" width="340" height="282" layout="absolute" title="视频接收端" id="playPan">
        <mx:VideoDisplay x="0" y="0" width="320" height="240" id="RecordVideo" />
    </mx:Panel>
    <mx:Button x="106" y="316" label="发布视频" fontWeight="normal" click="onPublishClick()"/>
    <mx:Button x="488" y="317" label="接收视频" fontWeight="normal" click="onRecordClik()"/>
    <mx:Script>
        <![CDATA[
            import flash.events.*;
            
            import mx.controls.Alert;
            
            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 var puN:String;
            private var reN:String;
            
            private function onPublishClick():void
            {
                pnc = new NetConnection();
                pnc.connect("rtmp://192.168.0.110/PublishStreams");
                pnc.addEventListener(NetStatusEvent.NET_STATUS,onPublishNetStatusHandler);
                
                cam = Camera.getCamera();
                mic = Microphone.getMicrophone();
                this.PublishVideo.attachCamera(cam);
                
                puN=this.publishName.text;
                //Alert.show(puN);
            }

            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(puN,"live");
                    
                    this.publishName.editable=false;
                }
            }
            
            private function onRecordClik():void
            {
                rnc = new NetConnection();
                
                reN=this.receiveName.text;
                
                rnc.connect("rtmp://192.168.0.110/PublishStreams");
                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(reN,"live");  //这里的publishName必须与发布流的流名一致
                    
                    this.receiveName.editable=false;
                }
            }
        ]]>
    </mx:Script>
    <mx:Label x="35" y="348" width="304" id="lbPublish"/>
    <mx:Label x="391" y="348" width="296" id="lbRecord"/>
    <mx:TextInput x="184" y="316" id="publishName"/>
    <mx:TextInput x="566" y="317" width="140" id="receiveName"/>
</mx:Application>
< >
分享
最佳答案
0

是因为防火墙的问题,把防火墙关闭就可以了

owner_hzh | 初学一级 |园豆:6 | 2013-06-11 15:42
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册