Jump to content
Search Community

jonespeople

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by jonespeople

  1. Hello guys, I've started using Greensock recently, specially TweenLite, it's such an amazing tool!

    Now I'm trying to use VideoLoader in an AIR app, to load some videos locally and play them one after another automatically. In order to keep memory as lower as possible, I load each video on its turn and unload them when they're not in use anymore. Even tough I cared for disposals and listener removals, I still have memory rising about 1.6Mb per hour (I've monitored it through Windows 8 Task Manager for almost 10 hours). The videos I've been using are three .flv files. I've tried to search a similar case on the forums, but couldn't find.

     

    Does anyone have a clue about what might be the cause of this memory leak? Am I correct to consider this memory I'm tracking as a valid memory leak indicator?

     

    Here is my code:
     

    package {
    	
    	import com.greensock.events.LoaderEvent;
    	import com.greensock.loading.VideoLoader;
    	import com.greensock.TweenLite;
    	import flash.display.MovieClip;
    	import flash.display.StageDisplayState;
    	import flash.events.Event;
    	import flash.filesystem.File;
    	import flash.system.System;
    	
    	public class Main extends MovieClip {
    		var paths:Array = [];//to store video files paths
    		var vl:VideoLoader;
    		var currentVideo:int = -1;
    		
    		public function Main() {
    			if(stage == null) {
    				this.addEventListener(Event.ADDED_TO_STAGE, init);
    			} else {
    				init();
    			}
    		}
    
    		public function init(e:Event = null) {
    			this.removeEventListener(Event.ADDED_TO_STAGE, init);
    			
    			stage.displayState = StageDisplayState.FULL_SCREEN;
    			
    			compoundPlaylist();
    		}
    
    		function compoundPlaylist() {
    			var fileList:Array = File.documentsDirectory.resolvePath("videofolder").getDirectoryListing();
    			var ext:String;
    			
    			//filter for .flv and .f4v files
    			for (var i:int = 0;i<fileList.length;i++) {
    				ext = fileList[i].extension.toLowerCase();
    				if(ext == "flv" || ext == "f4v") {
    					paths.push(fileList[i].url);
    				}
    			}
    			
    			if(paths.length > 0) {
    				loadVideo();//
    			} else {
    				trace("There are no videos in the specified folder");
    			}
    		}
    		
    		function loadVideo() {
    			try {
    				vl.dispose(true);
    			} catch(err:Error){}
    			vl = null;
    			
    			currentVideo++;
    			if(currentVideo == paths.length) currentVideo = 0;
    			
    			vl = new VideoLoader(paths[currentVideo], { container:this, onComplete:playVideo } );
    			vl.load();
    		}
    		
    		function playVideo(e:LoaderEvent) {
    			vl.content.width = 1280;//change this number according to your screen resolution
    			vl.content.height = 768;//change this number according to your screen resolution
    			vl.addEventListener(VideoLoader.VIDEO_COMPLETE, wait);
    			vl.playVideo();
    		}
    		
    		function wait(e:LoaderEvent) {
    			e.target.removeEventListener(VideoLoader.VIDEO_COMPLETE, wait);
    			TweenLite.delayedCall(5,loadVideo);
    		}
    	}
    }
    
    

    Thanks!

×
×
  • Create New...