Flash 视频播放器内存问题

发布于 2024-11-01 02:09:24 字数 917 浏览 0 评论 0原文

我制作了一个带有播放列表的视频播放器。大约 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情仇皆在手 2024-11-08 02:09:24

请不要转发问题
重新发布

    if(!vid){
      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); // you shouldnt add the video to2 display objects
      vid_frame.addChild(vid);
    }else{
      ns.play(VidReference);
   }

Please dont repost questions
Repost

    if(!vid){
      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); // you shouldnt add the video to2 display objects
      vid_frame.addChild(vid);
    }else{
      ns.play(VidReference);
   }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文