Flash 视频播放器内存问题
我制作了一个带有播放列表的视频播放器。大约 45 分钟后,声音停止了!视频继续播放。我播放短片(每个片段大约 3 到 4 分钟)。
播放器基于 2 个帧:
第 1 帧定义变量 VidReference,文件名:
VidReference = trackToPlay;
第 2 帧播放视频:
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
const buffer_time:Number = 2;
ns.bufferTime = buffer_time;
ns.client = this;
ns.play(VidReference);
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
vid_frame.addChild(vid);
视频播放完毕后,将转到第 1 帧(将新值放入 VidReference 变量)并返回到第 2 帧播放新视频。 我是否应该在每次加载新视频时删除视频对象?我是否真的在每次循环(帧 1 > 2)并将每个视频添加到 RAM 时声明一个新的视频对象,并最终压垮 Flash 播放器?
我听说过垃圾收集,但我不知道如何删除视频对象,以便从内存中清除它(以及视频本身)。
当我检查 System.totalMemory 时,每次加载新视频时它都会累加,我不知道如何从内存中删除旧视频。
I made a video player with a playlist. After around 45 min the sound stops! The video continues playing. I play short clips (about 3 to 4 min each).
The player is based on 2 frames:
Frame 1 defines the variable VidReference with the filename:
VidReference = trackToPlay;
Frame 2 plays the video:
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
const buffer_time:Number = 2;
ns.bufferTime = buffer_time;
ns.client = this;
ns.play(VidReference);
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
vid_frame.addChild(vid);
Once the video is done playing it goes to Frame 1 (to put the new value to the VidReference variable) and goes back to frame 2 to play the new video.
Am I supposed to delete the video object each time it loads a new video? Am I actually declaring a new video object each time I'm looping (frame 1 > 2) and adding each video to the RAM, and in the end overwhelming the flash player?
I've heard about garbage collecting but I wouldn't know how to delete the video object so it is cleared (and the video itself too) from the memory.
When I check System.totalMemory it's adding up each time a new video is loaded, I can't figure out how to delete old videos from the memory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请不要转发问题
重新发布
Please dont repost questions
Repost