本文介绍了如何发挥在动作脚本3使用的FLVPlayback之前检查FLV文件是否存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的动作脚本,我使用了的FLVPlayback 类来播放我的FLV文件。

I'm very new to the Action Scripting, I'm using the FLVPlayback class to play my FLV files.

如果我想打哪个不存在尚未然后我得到一个一个FLV文件的VideoError:1000与的消息无法连接到服务器或找到FLV服务器上的

If I'm trying to play a FLV file which is not existed yet then I am getting a "VideoError: 1000" with message of Unable to make connection to server or to find FLV on server.

我要检查使用该文件的URL或路径FLV文件存在,播放时通过FLV的FLVPlayback之前。任何人都可以请提出一个方法来做到这一点。

I want to check for the FLV file existence using the file URL or path, before playing that FLV by FLVPlayback. Can anybody please suggest a way to do that.

感谢

推荐答案

安全地捕获错误的唯一方法是将监听的事件,并采取相应的行动。下面是关于如何做那么一点点code片断:

The only way to catch the error safely is to listen for the fl.video.VideoEvent.STATE_CHANGE event and act accordingly. Here's a little code snippet on how to do so:

import fl.video.FLVPlayback;
import fl.video.VideoEvent;
import fl.video.VideoState;

var videoPlayer:FLVPlayback;
videoPlayer.addEventListener( VideoEvent.STATE_CHANGE, onVideoStateChange );
/** Bad source  **/
videoPlayer.source = "http://www.helpexamples.com/flash/video/caption_video_error.flv";
/** Good source **/
//videoPlayer.source = "http://www.helpexamples.com/flash/video/caption_video.flv";

function onVideoStateChange( evt:VideoEvent ):void
{
    var videoPlayer:FLVPlayback = evt.target as FLVPlayback;
    switch( evt.state )
    {
        case VideoState.CONNECTION_ERROR:
            trace( 'Connection error' );
            /**
             * Once you hit this event, you should run some logic to do one or more of the following:
             *   1. Show an error message to the user
             *   2. Try to load another video
             *   3. Hide the FLVPlayback component
             */
            break;
        default:
            trace( 'Player is: ' + evt.state );
    }
}

有关可能VideoState常量的完整列表,请访问的。

For a full list of possible VideoState constants, visit fl.video.VideoState.

这篇关于如何发挥在动作脚本3使用的FLVPlayback之前检查FLV文件是否存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 16:37