Flex中当视频播放到某一时间点时触发事件的样例代码

如果使用VideoDisplay,那么他有一个属性,叫cuePoints,值类型为数组,数组中的每个元素要求有两个属性,一个是name,类型为字符串,一个是time,类型为数字,表示触发时间的秒数。例如下面的代码,当播放到3s时将弹出一个对话框。这用来解决一些播放到某一时间点触发某事件的情况。
<?xml version="1.0" encoding="utf-8"?>
<!-- LearnCurPointEvent.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()">
    
<mx:Script>
        
<![CDATA[
            import mx.controls.Alert;
            import mx.events.CuePointEvent;
            [Bindable]
            private var myCuePoints:Array = [
            { name: "first", time: 3}]; 
            
            private function init():void{
                this.c_mainVideoDisplay.cuePoints = myCuePoints;
                this.c_mainVideoDisplay.addEventListener(CuePointEvent.CUE_POINT,cue_PointHandler);
            }
            
            private function cue_PointHandler(event:CuePointEvent):void{
                c_mainVideoDisplay.pause();
                Alert.show("It plays " + event.cuePointTime +"s.","",4,null,go);
            }
            
            private function go(event:Event):void{
                c_mainVideoDisplay.play();
            }
        
]]>
    
</mx:Script>
    
            
<mx:VideoDisplay id="c_mainVideoDisplay" width="320" height="240" 
                cuePointManagerClass
="mx.controls.videoClasses.CuePointManager"
                source
="phone.flv" 
                autoPlay
="false" />
            
<mx:Button label="播放" click="go(event)"/>
</mx:Application>


posted on 2008-01-20 21:44 咖啡屋的鼠标 阅读(1078) 评论(0)  编辑  收藏 所属分类: Flex


只有注册用户登录后才能发表评论。


网站导航:
 
<2008年1月>
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789

导航

统计

常用链接

留言簿(15)

随笔分类(52)

随笔档案(76)

文章分类(3)

文章档案(4)

新闻档案(1)

收藏夹

Flex

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜