flex_播放视频_本地_与_FMS端

flex_播放视频_本地_与_FMS端
  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"
  5                creationComplete="init();"
  6                minWidth="955" 
  7                minHeight="600">
  8     
  9     <fx:Script>
 10         <![CDATA[            
 11             import flash.display.Sprite;
 12             import flash.events.*;
 13             import flash.media.Video;
 14             import flash.net.NetConnection;
 15             import flash.net.NetStream;     
 16             import flash.events.Event;
 17                         
 18             private var videoName:String = "sample"; 
 19             private var connection:NetConnection; 
 20             private var stream:NetStream; 
 21             
 22             protected function button1_clickHandler(event:MouseEvent):void
 23             {
 24                 VideoExample();
 25                 connection.connect(textdz.text);
 26             }
 27             
 28             protected function button2_clickHandler(event:MouseEvent):void
 29             {
 30                 VideoExample();
 31                 connection.connect(null);
 32             }
 33             
 34             
 35             public function VideoExample():void 
 36             { 
 37                 connection = new NetConnection(); 
 38                 connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
 39                 connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
 40             } 
 41             
 42             private function netStatusHandler(event:NetStatusEvent):void 
 43             { 
 44                 switch (event.info.code) 
 45                 { 
 46                     case "NetConnection.Connect.Success": 
 47                         connectStream(); 
 48                         break; 
 49                     case "NetStream.Play.StreamNotFound": 
 50                         trace("Unable to locate video: " + videoName); 
 51                         break; 
 52                 } 
 53             } 
 54             
 55             private function connectStream():void 
 56             { 
 57                 stream = new NetStream(connection);
 58                 stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
 59                 stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
 60                 
 61                 stream.bufferTime = 0 ;    
 62                 var video:Video = new Video() ; 
 63                 video.smoothing = true ;
 64                 video.width = 480 ;
 65                 video.height = 290 ;
 66                 video.attachNetStream(stream); 
 67                 stream.play(texturl.text); 
 68                 sprct.addChild(video);
 69             } 
 70             
 71             private function securityErrorHandler(event:SecurityErrorEvent):void 
 72             {
 73                 trace("securityErrorHandler: " + event); 
 74             } 
 75             
 76             private function asyncErrorHandler(event:AsyncErrorEvent):void 
 77             { 
 78                 trace("asyncErrorHandler: " + event); 
 79             }
 80             
 81         ]]>
 82     </fx:Script>
 83 
 84     <s:Label x="21" y="26" text="地址:" verticalAlign="middle"/>
 85     <s:TextInput id="textdz" x="21" y="46" width="365" text="rtmp://localhost/vod"/>
 86     <s:TextInput id="texturl" x="19" y="83" width="365" text="../videos/liuhan_test.f4v"/>
 87     
 88     
 89     <s:Button x="18" y="118" label="开始_FMS" click="button1_clickHandler(event)"/>
 90     <s:Button x="116" y="118" width="79" label="本地视屏" click="button2_clickHandler(event)"/>
 91     
 92     <s:Scroller  x="116" y="152" width="637" height="355"   >
 93         <s:VGroup id="VG" width="100%" height="100%" >
 94             <s:VideoDisplay id="sprct" width="600" height="300" scaleMode="none"/>
 95         </s:VGroup>
 96     </s:Scroller>
 97     
 98 
 99 
100 </s:Application>
flex_播放视频_本地_与_FMS端

flex_播放视频_本地_与_FMS端

上一篇:BeeFramework


下一篇:Linux下设置动态库的方法