·您当前的位置:首页 > 技术教程 > AS2与AS3技术 >

[Flex]Flex和Red5制作视频直播播放器(2)

时间:2012-07-11 14:25JavaChenYang
客户端使用Flex play视频代码如下: ? xml version = 1.0 encoding = utf-8 ? mx:Application xmlns:mx = http://www.adobe.com/2006/mxml layout = absolute applicationComplete = init() mx:Script !--[CDATA[ i


客户端使用Flex play视频代码如下:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()"> 
  3.  
  4.     <mx:Script> 
  5.         <!--[CDATA[  
  6.               
  7.             import flash.display.*;  
  8.             import flash.utils.*;  
  9.             import flash.events.*;  
  10.             import flash.net.*;  
  11.             import flash.media.Video;  
  12.             import flash.media.Camera;  
  13.               
  14.             private var nc:NetConnection;  
  15.               
  16.             private function init():void{  
  17.                 nc = new NetConnection();  
  18.                 nc.connect("rtmp://58.116.56.68:1935/Flex01");  
  19.                 nc.addEventListener(NetStatusEvent.NET_STATUS,connectHandler);  
  20.             }  
  21.  
  22.             private function connectHandler(evt:NetStatusEvent):void{  
  23.                   
  24.                 var ns:NetStream = new NetStream(nc);  
  25.                 var video:Video=new Video() ;  
  26.                 video.width = 313;  
  27.                 video.height = 194;  
  28.                 video.attachNetStream(ns);  
  29.                 ns.play("red5");  
  30.                 videoDisplay.addChild(video);  
  31.                   
  32.             }  
  33.               
  34.         ]]--> 
  35.     </mx:Script> 
  36.       
  37.     <mx:Panel x="132" y="78" width="356" height="266" layout="absolute" title="现场直播" fontSize="14"> 
  38.         <mx:VideoDisplay x="10" y="10" width="320" height="193" id="videoDisplay"/> 
  39.     </mx:Panel> 
  40.       
  41. </mx:Application> 

 

热门文章推荐

请稍候...

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

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