繁体   English   中英

Flash Video Player的内存问题

[英]Flash Video player memory issue

我制作了一个带有播放列表的视频播放器。 大约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时,每次加载新视频时它都会累加,我不知道如何从内存中删除旧视频。

请不要转贴问题重新发布

    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);
   }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM