网上找到2款比较简单的VideoDisplay实例应用,很精简但很经典。

 第一款:普通播放器,包括Play,Stop,Pause,进程拖拽显示,声音调整,全屏等功能

主要是playheadTime,VideoEvent.PLAYHEAD_UPDATE,volume的应用

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="playinit()" width="500" height="400">  
  3.   
  4.     <mx:Script>  
  5.     <!--[CDATA[  
  6.        import mx.events.SliderEvent;  
  7.        import mx.events.VideoEvent;  
  8.        import flash.display.Stage;  
  9.         
  10.        private var isplaying:Boolean=false;        
  11.        private var video_url:String = "video/happy.flv";        
  12.        private var playPosition:Number;        
  13.        private var soundPosition:Number;  
  14.         
  15.        private function playinit():void{  
  16.         hs.enabled=false;  
  17.        }  
  18.         
  19.        private function flvplay(event:Event):void{  
  20.         flv_video.source=video_url;  
  21.         hs.enabled=true;  
  22.         if(isplaying){  
  23.          flv_video.pause();  
  24.          play_btn.label="播放"  
  25.         }else {  
  26.          flv_video.play();  
  27.          play_btn.label="暂停"  
  28.         }  
  29.         isplaying = !isplaying;   
  30.         flv_video.addEventListener(VideoEvent.PLAYHEAD_UPDATE, progressHandler);          
  31.        }        
  32.        private function progressHandler(event:VideoEvent):void{  
  33.         hs.value=flv_video.playheadTime;  
  34.        }   
  35.             
  36.        private function thumbPress(event:SliderEvent):void{  
  37.         flv_video.pause();  
  38.        }  
  39.        private function thumbChanges(event:SliderEvent):void{  
  40.         if(flv_video.playheadTime == -1){  
  41.       hs.value = 0;  
  42.       return;  
  43.      }  
  44.         playPosition = hs.value;  
  45.        }        
  46.        private function thumbRelease(event:SliderEvent):void{  
  47.         flv_video.playheadTime = playPosition;  
  48.         if(isplaying){  
  49.          flv_video.play();  
  50.         }else{  
  51.          flv_video.pause();  
  52.         }  
  53.        }  
  54.         
  55.        private function sound_thumbChanges(event:SliderEvent):void{  
  56.         soundPosition = hs_sound.value;  
  57.        }           
  58.        private function sound_thumbRelease(event:SliderEvent):void{  
  59.         flv_video.volume = soundPosition;  
  60.        }  
  61.         
  62.        private function formatTimes(value:int):String{  
  63.         var result:String = (value % 60).toString();  
  64.          
  65.           if (result.length == 1){  
  66.               result = Math.floor(value / 60).toString() + ":0" + result;  
  67.           } else {  
  68.               result = Math.floor(value / 60).toString() + ":" + result;  
  69.           }  
  70.           return result;  
  71.        }  
  72.         
  73.             private function display():void   
  74.             {     
  75.                 if(fs.selected)     
  76.                 {     
  77.                     stage.displayState="fullScreen";  
  78.                     application.width="100%";  
  79.                     application.height="100%";  
  80.                 }  
  81.                 else{     
  82.                     stage.displayState="normal";     
  83.                 }     
  84.             }   
  85.               
  86.     ]]-->  
  87.     </mx:Script>  
  88. <mx:VideoDisplay   />  
  89. <mx:ApplicationControlBar height="20" width="100%" bottom="67" x="0" horizontalAlign="center">  
  90.    <mx:HSlider />  
  91. </mx:ApplicationControlBar>  
  92. <mx:ApplicationControlBar width="100%" height="49" horizontalAlign="center" x="0" bottom="10">  
  93.    <mx:ApplicationControlBar width="123" cornerRadius="15">  
  94.     <mx:Button />  
  95.     <mx:Button  />  
  96.    </mx:ApplicationControlBar>  
  97.    <mx:ApplicationControlBar width="94" cornerRadius="15">  
  98.     <mx:Label />  
  99.    </mx:ApplicationControlBar>  
  100.    <mx:ApplicationControlBar cornerRadius="15" width="100">  
  101.     <mx:HSlider  />  
  102.    </mx:ApplicationControlBar>  
  103.    <mx:ApplicationControlBar color="#EC968F">  
  104.     <mx:CheckBox label="全屏" />  
  105.    </mx:ApplicationControlBar>  
  106. </mx:ApplicationControlBar>   
  107. </mx:Application>  

相关文章: