stop();
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var listener:Object = new Object();
listener.onMetaData = function(md:Object):void{};
listener.onPlayStatus = function(info : Object) : void {
trace("onPlayStatus:" +info.code + " " + info.duration);
if (info.code == "NetStream.Play.Complete") {
var endLoader:Loader = new Loader();
endLoader.load(new URLRequest("secondmovie.swf"));
addChild(endLoader);
initializeVideo();
}
};
ns.client = listener;
vid1.attachNetStream(ns);
var movietoplay:String = "firstmovie.flv";
ns.play(movietoplay);
function initializeVideo():void {
ns.close();
}
一旦flv完成播放,有人可以帮我加载swf吗?我想我只是没有加载swf,因为flv正确播放。
答案 0 :(得分:2)
当视频完成事件触发时,swf应该已经加载,这样它会立即开始播放而不是等待它加载,然后播放。只需预加载swf,视频播放完毕后,将swf添加到显示列表中。
当你等待视频完成开始加载,而不是播放swf时,意味着在开始播放之前会有一个与swf大小成比例的延迟
stop(); //start the swf loading process var endLoader:Loader = new Loader(); endLoader.load(new URLRequest("secondmovie.swf")); //start the video var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); var listener:Object = new Object(); listener.onMetaData = function(md:Object):void{}; listener.onPlayStatus = function(info : Object) : void { trace("onPlayStatus:" +info.code + " " + info.duration); if (info.code == "NetStream.Play.Complete") { //unless the swf size is really big or the video really short , //the swf should be loaded //add it it should start playing straight away. addChild(endLoader); initializeVideo(); } }; ns.client = listener; vid1.attachNetStream(ns); var movietoplay:String = "firstmovie.flv"; ns.play(movietoplay); function initializeVideo():void { ns.close(); }