# Video Memory Problem

**URL:** <https://forum.kirupa.com/t/video-memory-problem/311883>\
**Category:** Uncategorized\
**Created:** [July 19, 2010, 2:43pm UTC](https://forum.kirupa.com/t/video-memory-problem/311883 "2010-07-19T14:43:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![actionbob](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@actionbob](https://forum.kirupa.com/u/actionbob)\
**Post date:** [July 19, 2010, 2:43pm UTC](https://forum.kirupa.com/t/video-memory-problem/311883/1 "2010-07-19T14:43:01Z")

</div>

Hello all,

I am having a flash video problem. I am trying to make my own video player that will also play images and swfs. Right now I am only playing video (.h264 and On2 formats). My video player will always crash in about 4-12 hours. I have tested playing my playlist using the FLVPlayback component, and that doesn’t crash leading me to believe there is something in my code that blows everything up.

here is my code…

private function  
playPlaylist ( increment : Number = 0 ) : void  
{  
curFile += increment ;  
if ( curFile \>= Files.length )  
{  
curFile = 0 ;  
}

```
		var t : Object = Files[curFile] ;
		
		switch ( t.type )
		{
			case "img":
				if ( t.image != null )
				{
					resizeImage ( t.image );
					addChild ( t.image ) ;
					if ( timer != null )
					{
						timer = new Timer ( (( c_imageHold - c_timeForTween ) * 1000),1);
						timer.addEventListener ( TimerEvent.TIMER , imageComplete,false,0,true) ;
					}
					timer.start();
				}
				else if ( t.url != null )
				{
					
				}
				break ;
			case "swf" :
				if ( t.swf != null )
				{
					resizeImage ( t.swf) ;
					addChild ( t.swf ) ;
					t.swf.addEventListener ( WandEvent.SWF_END,handleSwf,false,0,true ) ;
					t.swf.addEventListener ( WandEvent.SWF_START,handleSwf ,false,0,true) ;
					t.swf.gotoAndPlay(1);
				}
				else if ( t.url != null )
				{
					
				}
				break;
			
			case "flv":
			case "vid":
				if ( netCon == null)
				{
					setUpVideoPlayer ( );
				}
				netStream.play(wand.filePrefix + t.url );
				addChild(videoPlayer);
				break;
			default :
				trace( "-FILE NOT FOUND!-" ) ;
				break ;
		}
	}
	
	private function
	setUpVideoPlayer ( ) :void
	{
		netCon = new NetConnection ( );
		netCon.connect(null);
		netStream = new NetStream ( netCon ) ;
		netStream.addEventListener ( NetStatusEvent.NET_STATUS, VideoComplete ,false,0,true) ;
		netStream.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler,false,0,true);
		metaClient = new Object ( ) ;
		metaClient.onMetaData = metaData ;
		metaClient.onXMPData = xmpData ;
		netStream.client = metaClient ;
		videoPlayer = new Video ( vidSize.x,vidSize.y ) ;
		videoPlayer.attachNetStream(netStream ) ;
	}
	
	private function
	metaData ( e : Object ) : void
	{
		
	}
	
	private function
	xmpData ( e : Object) : void
	{
		
	}
	
	private function
	VideoComplete ( stats : NetStatusEvent ) : void
	{
		switch ( stats.info.code )
		{	
			case "NetStream.buffer.Empty":
			case "NetStream.Play.StreamNotFound" :
			case "NetStream.Play.Failed":
			case "NetStream.Play.InsufficientBW":
			case "NetStream.Connect.Failed" :
			case "NetStream.Failed" :
				break ;
					
			case "NetStream.Play.Stop" :
				if ( Files.length &gt; 1 )
				{
					trace ( "REMOVING FLV");
					removeChild(videoPlayer);

					playPlaylist ( 1 ) ;
				}
				else
				{
					netStream.seek ( 0 ) ;
					netStream.play(wand.filePrefix + Files[curFile].url );
				}
				dispatchEvent ( new Event ( "DONE" , false ,false )) ;
				break ;
		}
		
	}
	
	private function
	ioErrorHandler ( e :IOErrorEvent ) : void
	{
		//Do nothing.
		removeChild(videoPlayer);
		playPlaylist ( 1 ) ;
	}
```
