<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
width="410"
height="310"
layout="absolute" >
<mx:Script>
<![CDATA[
import mx.events.SliderEvent; // 这里是导入所需要的类, 用 import 关键字, 没什么好说的
import mx.events.VideoEvent;
// 自定义一个 playingMove() 函数, 作用: 影片播放时, id 为 " my_hs " 的HSlider 控件的值为影片的播放时间, 且最大值为影片的总时长
private function playingMove(event:VideoEvent):void{
my_hs.value = flvideo.playheadTime;
my_hs.maximum=flvideo.totalTime;
}
// 自定义 hs_onChange() 函数, 作用: 当用户拖拉 HSlider 控件使其值发生改变时, 影片的播放头就处于其值处, 即正在播放时间处于其值处
private function hs_onchange(event:SliderEvent):void{
flvideo.playheadTime = event.value;
}
//停止
private function stopMovie(event:MouseEvent):void{
flvideo.stop();
}
//播放
private function playMovie(event:MouseEvent):void{
playUrl(flvideo.source);
}
//暂停
private function pauseMovie(event:MouseEvent):void{
flvideo.pause();
}
private function playUrl(url:String):void{
if(flvideo.playing)
flvideo.stop();
flvideo.source = url;
flvideo.play();
}
private function displayStateChange():void{
var flag:int=1;
if(stage.displayState == StageDisplayState.FULL_SCREEN){
this.width=410;
this.height=310;
stage.displayState = StageDisplayState.NORMAL;
}else{
this.width=Capabilities.screenResolutionX;
this.height=Capabilities.screenResolutionY;
stage.displayState = StageDisplayState.FULL_SCREEN;
}
if(flag!=2){
stage.addEventListener(FullScreenEvent.FULL_SCREEN ,fullScreenHandler);
flag=2;
}
}
private function fullScreenHandler(event:FullScreenEvent):void{
if(!event.fullScreen){
this.width=410;
this.height=310;
}
}
]]>
</mx:Script>
<!-- complete="this.flvideo.play()" 重复播放-->
<mx:VideoDisplay id="flvideo" playheadUpdate="playingMove(event)"
source="Butterfly.flv" left="10" right="10" top="10" bottom="55"/>
<mx:Button label="Play" x="10" y="279" width="60" click="playMovie(event)"/>
<mx:Button x="81" y="279" label="stop" width="60" click="stopMovie(event)"/>
<mx:Button x="266" y="279" label="pause" width="60" click="pauseMovie(event)"/>
<mx:Label x="1" y="258" text="progress:" width="72" textAlign="right"/>
<mx:Button x="341" y="279" label="full" width="60" click="displayStateChange()"/>
<mx:HSlider minimum="0" id="my_hs" change="hs_onchange(event)" x="70" y="262" width="210"/>
<mx:HSlider x="320" y="262" width="88"/>
</mx:Application>