#ifndef _VIDEO_LINE_MODULE
#define _VIDEO_LINE_MODULE

#include "simpleLineModule.h"
#include "ofMain.h"
#include "ofVec3f.h"
#include "timeStroke.h"
#include "lineTexture.h"


#ifdef TARGET_OSX
	#include <pthread.h>
	#include <semaphore.h>
#endif

class videoLineModule : public simpleLineModule {
	
	public:
		
		videoLineModule();
		
		void 		setMovie(char * movieName);
		
		void 		reset();
		void 		setup();
		void 		update();
		void 		updatePts();
		void 		draw(float offsetx, float offsety);
		
		virtual bool 		bProduceSound(){return bHaveSound;};
		
		
		//---------------------------------------------
		// threads......
		void 		loadIntoMoviePlayer();	

		#ifdef TARGET_OSX
				pthread_t	    myThread;
				pthread_mutex_t myMutex;
		#else
				HANDLE 		myThread;		
		#endif
	
		int 		bMovieLoaded;
		
		//---------------------------------------------
		
		
		// the bAmIdone is now moidifed to use now the endPct, although I started to like the lags...
		
		bool 		bAmIDone(){ return pct >= MIN(0.99f, ts.endPct) ? true : false; };
		bool 		bHaveNewPoint();
		ofVec3f 	getNewPoint();
		
		//--------------- these could have better names
		
		int 			myVideoPlayer;
		char 			path[1024];
		char 			movieName[255];
		float 			pct;
		ofVec3f 		pointPos;
		bool 			bPointNew;
		timeStroke		ts;
		float 			fadeIn;
		bool 			bHaveSound;
		float 			volume;
	
};

#endif	