加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

FLEX 播放 flv文件

发布时间:2020-12-15 04:02:42 所属栏目:百科 来源:网络整理
导读:1.先来做一个最简单的例子,使用VideoDisplay组件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 ?xml version= "1.0" ? encoding= "utf-8" ? s:Application xmlns:fx= "http://ns.a

1.先来做一个最简单的例子,使用VideoDisplay组件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?xml version= "1.0"? encoding= "utf-8" ?>
<s:Application xmlns:fx= "http://ns.adobe.com/mxml/2009"
??????????????? xmlns:s= "library://ns.adobe.com/flex/spark"
xmlns:mx= library://ns.adobe.com/flex/mx"? minWidth= "955"? minHeight= "600" >
???? <s:layout>
???????? <s:BasicLayout/>
</s:layout>
?
<fx:Script>
<![CDATA[
???????????? protected? function? button1_clickHandler(event:MouseEvent): void
???????????? {
???????????????? vd.play();
}
?
button2_clickHandler(event:MouseEvent): void
{
vd.pause();
}
?
?
button3_clickHandler(event:MouseEvent): void
{
vd.stop();
}
?
]]>
</fx:Script>
?
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
?
</fx:Declarations>
<s:VideoDisplay id= "vd"? source= "http://localhost/flex/M2U00883.flv"? x= "59"? y= "83"? width= "496"? height= "335"? autoPlay= "false" >
</s:VideoDisplay>
<s:BorderContainer x= "63"? "427"? "43" >
<s:Button x= "105"? "10"? label = "播放"? click= "button1_clickHandler(event)" />
"212"? "暂停"? "button2_clickHandler(event)" />
"327"? "停止"? "button3_clickHandler(event)" />
</s:BorderContainer>?
</s:Application>

?

这个例子非常简单,就是设置好Flv文件的位置,然后通过三个按钮控制视频播放

2.不妨改用VideoPlayer组件,一般的视频控制都有了:播放、暂停、进度拖动、声音控制、是否全屏

16
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
?
</fx:Declarations>
<s:VideoPlayer id= >
</s:VideoPlayer>
?????
执行一下看看效果,很简单吧!

3.VideoPlayer组件添加全屏按钮tooltip,以及在视频播放完毕时执行事件

37
import? mx.controls.Alert;
mx.events.FlexEvent;
?????????????
org.osmf.events.TimeEvent;
?
vd_initializeHandler(event:FlexEvent): void
{
vd.fullScreenButton.toolTip = "进入全屏" ;
}
?
vd_completeHandler(event:TimeEvent): void
{
Alert.show( "视频播放完毕" );
}
?
]]>
</fx:Script>
?
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
?
</fx:Declarations>
"false"? initialize= "vd_initializeHandler(event)"? complete= "vd_completeHandler(event)" >
</s:VideoPlayer>
</s:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!