开发者

Flash Video player memory issue

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 vid开发者_开发技巧eo 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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜