在 Flash/Actionscript 中播放 .mpg 视频 [英] Playing .mpg videos in Flash/Actionscript

查看:28
本文介绍了在 Flash/Actionscript 中播放 .mpg 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以加载 .mpg 文件并通过 actionscript/flash 播放?

Is it possible to load .mpg file and play it through actionscript/flash ?

该代码适用于 mp4 视频文件.如果无法播放 mpg 文件,实现它的一种方法是转换这些文件?

The code works well with mp4 video files. If not possible to play mpg files, the one way to make it work is converting these files?

package  {
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.events.AsyncErrorEvent;
    import flash.media.Video;
    import se.svt.caspar.template.CasparTemplate;

    public class data extends CasparTemplate {
        var nc:NetConnection;
        var ns:NetStream;
        var vid:Video;
        var textfield:TextField;

        public function data() {

            nc = new NetConnection();
            nc.connect(null);

            ns = new NetStream(nc);
            ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
            ns.play("test3.MPEG");

            vid = new Video();
            vid.attachNetStream(ns);
            addChild(vid);

        }

        function asyncErrorHandler(event:AsyncErrorEvent):void
        {
            trace("error");
        }


    }

}

推荐答案

Flash 播放器可以播放的视频格式数量有限:Sorenson Spark H263 (FLV)、On2 VP6 (FLV) 和 H.264(MP4、M4V、F4V、3GPP).

Flash player can play a limited number of video formats : Sorenson Spark H263 (FLV), On2 VP6 (FLV) and H.264 (MP4, M4V, F4V, 3GPP).

因此,对于您的 mpeg 视频,您必须将其转换为这些支持的格式之一.

So for your mpeg video you have to convert it to one of these supported formats.

有关详细信息,您可以查看 Flash 播放器支持的编解码器 在这里了解更多视频格式,也您可以查看维基百科.

For more information, you can see supported codecs for flash player and here to understand more video formats, also you can take a look on wikipedia.

这篇关于在 Flash/Actionscript 中播放 .mpg 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆