播放器一般是由屏幕和按钮以及进度条这三个部分组成.那么我们在DESIGN的界面下,把VideoDisplay ,BUTTON,和HSLIDER这三个组件按照你喜欢的排列好.然后分别把命名ID;
如
ViderDisplay:flvvideo;
Button:btn(在这个例子里可以不用命名ID);
hSlider:hs;
回到Source界面:
先设置VideoDisplay.
<mx:VideoDisplay id="flvvideo" playheadUpdate="mover(event)" >
要注意的是playheadUpdate ,他是VideoDisplay的一个内部命令,大概意思就是在视频播放的情况下不停的调用程序(比如:MOVER(EVENT));同时你也会看到playheadUpdateInterval这个命令,他可以设置多长时间调用一次事件,(比如:1000就是1秒时间).
接着设置BUTTON.
<mx:Button label="Play" click="flvideo.source='videos/xxx.flv'"/>
当然source后头,你可以随便设置你FLV文件的地址,要注意的是单引号和双引号的区别.
最后就是设置:进度条拉,也就是HSlider
<mx:HSlider minimum="0" id="hs" change="changeHandler(event)" />
放上change ,是为了可以拉动视频的进度.
三个主要部分基本已经设置完毕.接下来该是script.我就直接把全部代码贴上了:
import mx.events.SliderEvent;
import mx.events.VideoEvent;
private function mover(event:VideoEvent):void{
trace(flvideo.playheadTime);
hs.value = flvideo.playheadTime;
hs.maximum=flvideo.totalTime;
}
private function changeHandler(event:SliderEvent):void{
flvideo.playheadTime = event.value;
}
这样基本上就能实现一个简单的视频播放器了.:)
作者:gdgzboy@牛C网
地址:http://www.niuc.net/post/185/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
牛C网推荐您再看看以下日志:
Degrafa
SalesBuilder on AIR: Local Database, Data Sync, and Native Drag-and-Drop
SQLite Admin for AIR 1.0
FLEX 调用外部SWF
Building database-driven Flex applications without writing (Client- or server-side) code
避免在ActionScript中使用整型(ints)
Flex 2- 打开下一代富互联网应用之门
Flex ColdFusion 上传程序
Building Collaborative Applications with Flex Data Services and Flash Media Server
the ILog Elixir Components
Degrafa
SalesBuilder on AIR: Local Database, Data Sync, and Native Drag-and-Drop
SQLite Admin for AIR 1.0
FLEX 调用外部SWF
Building database-driven Flex applications without writing (Client- or server-side) code
避免在ActionScript中使用整型(ints)
Flex 2- 打开下一代富互联网应用之门
Flex ColdFusion 上传程序
Building Collaborative Applications with Flex Data Services and Flash Media Server
the ILog Elixir Components
New MDI-style Trader Desktop with Flex and Ap
一款很酷的FLEX 3D作品





