memory - flash player crashes while looping over movies -
i'm trying realize kind of slideshow in flash, loops on 100 h.264 encoded movies. i'm using netconnection , netstream classes connecting files locally on harddisk (see code below).
private function playmovie():void { var currentmovie:string = movies[index]; index = (index + 1) % movies.length; netconnection = new netconnection(); netconnection.connect(null); if(netstream != null) { netstream.removeeventlistener(netstatusevent.net_status, netstatushandler); netstream = null; } netstream = new netstream(netconnection); netstream.client = this; netstream.addeventlistener(netstatusevent.net_status, netstatushandler); stagevideo.attachnetstream(null); stagevideo.attachnetstream(netstream); netstream.play(currentmovie); } private function netstatushandler(evt:netstatusevent):void { if(evt.info.code == "netstream.play.stop") { playmovie(); } } public function onmetadata(e:object):void { netstream.seek(int(e["duration"])); } public function onxmpdata (e:object):void {}
the problem memory usage of flashplayer increases every movie , when reaching 1.3gb ends without errormessage.
my question obviously: how can fix that?
you must call netconnection.close() free resources, otherwise memory usage increase see it. better practice, though, keep same netconnection , netstream objects, once created, play different videos:
private function playmovie():void { var currentmovie:string = movies[index]; index = (index + 1) % movies.length; if ( netconnection == null ) { netconnection = new netconnection(); netconnection.connect(null); } if ( netstream == null ) { netstream = new netstream(netconnection); netstream.client = this; netstream.addeventlistener(netstatusevent.net_status, netstatushandler); stagevideo.attachnetstream(netstream); } netstream.play(currentmovie); }
Comments
Post a Comment