问题
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