简体   繁体   中英

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 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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