网上找到2款比较简单的VideoDisplay实例应用,很精简但很经典。
第一款:普通播放器,包括Play,Stop,Pause,进程拖拽显示,声音调整,全屏等功能
主要是playheadTime,VideoEvent.PLAYHEAD_UPDATE,volume的应用
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="playinit()" width="500" height="400">
- <mx:Script>
- <!--[CDATA[
- import mx.events.SliderEvent;
- import mx.events.VideoEvent;
- import flash.display.Stage;
- private var isplaying:Boolean=false;
- private var video_url:String = "video/happy.flv";
- private var playPosition:Number;
- private var soundPosition:Number;
- private function playinit():void{
- hs.enabled=false;
- }
- private function flvplay(event:Event):void{
- flv_video.source=video_url;
- hs.enabled=true;
- if(isplaying){
- flv_video.pause();
- play_btn.label="播放"
- }else {
- flv_video.play();
- play_btn.label="暂停"
- }
- isplaying = !isplaying;
- flv_video.addEventListener(VideoEvent.PLAYHEAD_UPDATE, progressHandler);
- }
- private function progressHandler(event:VideoEvent):void{
- hs.value=flv_video.playheadTime;
- }
- private function thumbPress(event:SliderEvent):void{
- flv_video.pause();
- }
- private function thumbChanges(event:SliderEvent):void{
- if(flv_video.playheadTime == -1){
- hs.value = 0;
- return;
- }
- playPosition = hs.value;
- }
- private function thumbRelease(event:SliderEvent):void{
- flv_video.playheadTime = playPosition;
- if(isplaying){
- flv_video.play();
- }else{
- flv_video.pause();
- }
- }
- private function sound_thumbChanges(event:SliderEvent):void{
- soundPosition = hs_sound.value;
- }
- private function sound_thumbRelease(event:SliderEvent):void{
- flv_video.volume = soundPosition;
- }
- private function formatTimes(value:int):String{
- var result:String = (value % 60).toString();
- if (result.length == 1){
- result = Math.floor(value / 60).toString() + ":0" + result;
- } else {
- result = Math.floor(value / 60).toString() + ":" + result;
- }
- return result;
- }
- private function display():void
- {
- if(fs.selected)
- {
- stage.displayState="fullScreen";
- application.width="100%";
- application.height="100%";
- }
- else{
- stage.displayState="normal";
- }
- }
- ]]-->
- </mx:Script>
- <mx:VideoDisplay />
- <mx:ApplicationControlBar height="20" width="100%" bottom="67" x="0" horizontalAlign="center">
- <mx:HSlider />
- </mx:ApplicationControlBar>
- <mx:ApplicationControlBar width="100%" height="49" horizontalAlign="center" x="0" bottom="10">
- <mx:ApplicationControlBar width="123" cornerRadius="15">
- <mx:Button />
- <mx:Button />
- </mx:ApplicationControlBar>
- <mx:ApplicationControlBar width="94" cornerRadius="15">
- <mx:Label />
- </mx:ApplicationControlBar>
- <mx:ApplicationControlBar cornerRadius="15" width="100">
- <mx:HSlider />
- </mx:ApplicationControlBar>
- <mx:ApplicationControlBar color="#EC968F">
- <mx:CheckBox label="全屏" />
- </mx:ApplicationControlBar>
- </mx:ApplicationControlBar>
- </mx:Application>