·您当前的位置:首页 > 技术教程 > Rtmp技术 >

[FMS]FMS实现视频聊天的代码示例(含发布端和接收端)(2)

时间:2012-10-23 23:12cnblogs.com
接收端(Receive.mxml) ? xml version = 1.0 encoding = utf-8 ? s:Application xmlns:fx = http://ns.adobe.com/mxml/2009 xmlns:s = library://ns.adobe.com/flex/spark xmlns:mx = library://ns.adobe.com/flex/m

接收端(Receive.mxml)

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
  3.                xmlns:s="library://ns.adobe.com/flex/spark" 
  4.                xmlns:mx="library://ns.adobe.com/flex/mx" initialize="init()"> 
  5.     <s:layout> 
  6.         <s:BasicLayout/> 
  7.     </s:layout> 
  8.     <fx:Declarations> 
  9.         <!-- 将非可视元素(例如服务、值对象)放在此处 --> 
  10.     </fx:Declarations> 
  11.     <fx:Script> 
  12.         <![CDATA[ 
  13.             import mx.core.UIComponent; 
  14.             private var nc:NetConnection; 
  15.             private function init():void 
  16.             { 
  17.                 nc = new NetConnection(); 
  18.                 nc.connect("rtmp://192.168.1.16/virtualShow"); 
  19.                 nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatus); 
  20.                 nc.client = this; 
  21.             } 
  22.             private function onNetStatus(evt:NetStatusEvent):void 
  23.             { 
  24.                 var ns:NetStream = new NetStream(nc); 
  25.                 ns.play("hxw"); 
  26.                 var video:Video = new Video(); 
  27.                 video.attachNetStream(ns); 
  28.                 var uiBox:UIComponent = new UIComponent(); 
  29.                 uiBox.addChild(video); 
  30.                 this.addElement(uiBox); 
  31.             } 
  32.             public function onBWDone():void 
  33.             { 
  34.             } 
  35.         ]]> 
  36.     </fx:Script> 
  37. </s:Application> 

 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器