判断VideoDisplay组件当前的播放状态。播放|缓冲。

stateChange="videoDisplay_stateChange(event);"

 

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/01/determining-a-videodisplay-controls-current-playback-state-using-the-state-property-and-statechange-event/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="horizontal"
        verticalAlign
="middle"
        backgroundColor
="white">

    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.VideoEvent;

            [Bindable]
            private var arrColl:ArrayCollection = new ArrayCollection();

            private const VIDEO_URL:String = "http://www.helpexamples.com/flash/video/water.flv";

            private function videoDisplay_stateChange(evt:VideoEvent):void {
                /* videoDisplay.state == evt.state */
                arrColl.addItem({label:videoDisplay.state});
                progressBar.label = evt.state;
            }

            private function button_click(evt:MouseEvent):void {
                /* Reset ArrayCollection object. */
                arrColl = new ArrayCollection();
                /* Set the Canvas container to visible. */
                canvas.visible = true;
                /* If video is currently playing, stop playback. */
                if (videoDisplay.playing) {
                    videoDisplay.stop();
                }
                /* Set VideoDisplay control's source property and start
                   video playback. */
                videoDisplay.source = VIDEO_URL;
                videoDisplay.play();
            }

            private function videoDisplay_playheadUpdate(evt:VideoEvent):void {
                progressBar.setProgress(evt.playheadTime, videoDisplay.totalTime);
            }
        
]]>
    </mx:Script>

    <mx:ApplicationControlBar dock="true">
        <mx:Button id="button"
                label
="load movie"
                click
="button_click(event);" />
    </mx:ApplicationControlBar>

    <mx:Canvas id="canvas" visible="false">
        <mx:VideoDisplay id="videoDisplay"
                playheadUpdateInterval
="50"
                stateChange
="videoDisplay_stateChange(event);"
                playheadUpdate
="videoDisplay_playheadUpdate(event);" />

        <mx:ProgressBar id="progressBar"
                label
=""
                labelPlacement
="center"
                mode
="manual"
                bottom
="0"
                horizontalCenter
="0" />
    </mx:Canvas>

    <mx:List id="list"
            dataProvider
="{arrColl}"
            width
="100" />

</mx:Application>

本文转自jiahuafu博客园博客,原文链接http://www.cnblogs.com/jiahuafu/archive/2010/11/12/1875817.html如需转载请自行联系原作者


jiahuafu

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值