Playing .mpg videos in Flash/Actionscript

狂风中的少年 提交于 2019-12-18 09:45:13

问题


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

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");
        }


    }

}

回答1:


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

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

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.



来源:https://stackoverflow.com/questions/27798605/playing-mpg-videos-in-flash-actionscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!