Flash 播放器在循环播放电影时崩溃
我正在尝试在 Flash 中实现某种幻灯片放映,它会循环播放大约 100 个 h.264 编码的电影。我正在使用 NetConnection 和 NetStream 类连接到本地硬盘上的文件(请参阅下面的代码)。
private function playMovie():void
{
var currentMovie:String = movies[index];
index = (index + 1) % movies.length;
netConnection = new NetConnection();
netConnection.connect(null);
if(netStream != null)
{
netStream.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
netStream = null;
}
netStream = new NetStream(netConnection);
netStream.client = this;
netStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stageVideo.attachNetStream(null);
stageVideo.attachNetStream(netStream);
netStream.play(currentMovie);
}
private function netStatusHandler(evt:NetStatusEvent):void
{
if(evt.info.code == "NetStream.Play.Stop")
{
playMovie();
}
}
public function onMetaData(e:Object):void
{
netStream.seek(int(e["duration"]));
}
public function onXMPData (e:Object):void {}
问题是 Flashplayer 的内存使用量随着每部电影的增加而增加,当达到大约 1.3GB 时,它就会自行结束,没有任何错误消息。
我的问题显然是:我该如何解决这个问题?
I'm trying to realize kind of a slideshow in flash, which loops over about 100 h.264 encoded movies. I'm using the NetConnection and NetStream classes for connecting to the files locally on my harddisk (see code below).
private function playMovie():void
{
var currentMovie:String = movies[index];
index = (index + 1) % movies.length;
netConnection = new NetConnection();
netConnection.connect(null);
if(netStream != null)
{
netStream.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
netStream = null;
}
netStream = new NetStream(netConnection);
netStream.client = this;
netStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stageVideo.attachNetStream(null);
stageVideo.attachNetStream(netStream);
netStream.play(currentMovie);
}
private function netStatusHandler(evt:NetStatusEvent):void
{
if(evt.info.code == "NetStream.Play.Stop")
{
playMovie();
}
}
public function onMetaData(e:Object):void
{
netStream.seek(int(e["duration"]));
}
public function onXMPData (e:Object):void {}
the problem is that the memory usage of the flashplayer increases with every movie and when reaching about 1.3gb it just ends itself without any errormessage.
my question obviously: how can i fix that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须调用 NetConnection.close() 来释放资源,否则您的内存使用量将会增加,如您所见。不过,更好的做法是,在创建后保留相同的 NetConnection 和 NetStream 对象来播放不同的视频:
You must call NetConnection.close() to free the resources, otherwise your memory usage will increase as you see it. It is better practice, though, to keep the same NetConnection and NetStream objects, once created, to play different videos: