Example #1
0
//--------------------------------------------------------------
void testApp::setup()
{
	ofSetLogLevel(OF_LOG_VERBOSE);
	
	string videoPath = ofToDataPath("../../../videos/720p.mov", true);
	
	// this will just set videoPath to the first video in the videos folder, if any.
	ofDirectory currentVideoDirectory(ofToDataPath("videos", true));
	if (currentVideoDirectory.exists()) 
	{
		currentVideoDirectory.listDir();
		vector<ofFile> files = currentVideoDirectory.getFiles();
		if (files.size()>0) 
		{
			videoPath = files[0].path();
		}		
	}
	
	//Somewhat like ofFboSettings we may have a lot of options so this is the current model
	ofxOMXPlayerSettings settings;
	settings.videoPath = videoPath;
	settings.useHDMIForAudio = true;	//default true
	settings.enableTexture = true;		//default true
	settings.enableLooping = true;		//default true

	omxPlayer.setup(settings);
	
}
//--------------------------------------------------------------
void ofApp::setup(){
	ofSetLogLevel(OF_LOG_VERBOSE);
	ofSetVerticalSync(true);
    
    //  BCM
    //
    int pinMax = 4;
    int pinMap[4] = {18,27,22,23};
    
#ifdef TARGET_OPENGLES
    consoleListener.setup(this);
    if(wiringPiSetupSys() == -1){
        printf("Error on wiringPi setup\n");
        return;
    }
#endif
	
	//this will let us just grab a video without recompiling
	ofDirectory currentVideoDirectory("videos");
    
	if (currentVideoDirectory.exists()) {
		currentVideoDirectory.listDir();
		vector<ofFile> files = currentVideoDirectory.getFiles();
		
		for (int i=0; i<files.size(); i++) {
            
            if(i>=pinMax)
                break;
            
            Channel newChannel;
            newChannel.pin = pinMap[i];
#ifdef TARGET_OPENGLES

            //  Pins
            pinMode(newChannel.pin, INPUT);
            
            //  Video Player
			ofxOMXPlayerSettings settings;
			settings.videoPath = files[i].path();
			settings.useHDMIForAudio = true;	//default true
			settings.enableTexture = true;		//default true
			settings.enableLooping = false;		//default true
			settings.enableAudio = false;		//default true, save resources by disabling
			ofxOMXPlayer* player = new ofxOMXPlayer();
			player->setup(settings);
#else
            ofVideoPlayer *player = new ofVideoPlayer();
            player->loadMovie(files[i].path());
#endif
            newChannel.video = player;
            newChannel.state = false;
			channels.push_back(newChannel);
		}
	}
    
    nActive = -1;
}
//--------------------------------------------------------------
void ofApp::setup()
{
	consoleListener.setup(this);
	ofHideCursor();
	videoCounter = 0;
	
	string videoPath = ofToDataPath("../../../videos/big_buck_bunny_MpegStreamclip_720p_h264_50Quality_48K_256k_AAC.mov", true);
	
	//this will let us just grab a video without recompiling
	ofDirectory currentVideoDirectory(ofToDataPath("../../../videos/current", true));
	bool doRandomSelect		= true;
	if (currentVideoDirectory.exists()) 
	{
		//option to put multiple videos in folder to test
		currentVideoDirectory.listDir();
		files = currentVideoDirectory.getFiles();
		if (files.size()>0) 
		{
			if (doRandomSelect && files.size()>1) {
				videoPath = files[ofRandom(files.size())].path();
			}else 
			{
				videoPath = files[0].path();
			}
		}		
	}
	
	ofLogVerbose() << "using videoPath : " << videoPath;
	settings.videoPath = videoPath;
	settings.useHDMIForAudio = true;		//default true
	
	//settings.enableTexture = false;		//default true, uncomment for direct-to-screen mode
	if (files.size()>0)
	{
		//we don't want to loop if we are switching files
		settings.enableLooping = false;		//default true
	}
	settings.enableAudio = true;
	settings.listener = this; //this app extends ofxOMXPlayerListener so it will receive events ;
	omxPlayer.setup(settings);
	
	doPixels = false;
	doDrawInfo = true;
	doShader = true;
	if (settings.enableTexture && doShader) 
	{
		shader.load("shaderExample");
		fbo.allocate(ofGetWidth(), ofGetHeight());
		fbo.begin();
			ofClear(0, 0, 0, 0);
		fbo.end();
		//turn off until s key hit
		doShader = false;
	}
	
}
Example #4
0
//--------------------------------------------------------------
void testApp::setup()
{
	ofSetLogLevel(OF_LOG_VERBOSE);
	
	
	
	string videoPath = ofToDataPath("big_buck_bunny_MpegStreamclip_720p_h264_50Quality_48K_256k_AAC.mov", true);
	
	//this will let us just grab a video without recompiling
	ofDirectory currentVideoDirectory("/home/pi/videos/current");
	if (currentVideoDirectory.exists()) 
	{
		currentVideoDirectory.listDir();
		vector<ofFile> files = currentVideoDirectory.getFiles();
		if (files.size()>0) 
		{
			videoPath = files[0].path();
		}		
	}
	
	//Somewhat like ofFboSettings we may have a lot of options so this is the current model
	ofxOMXPlayerSettings settings;
	settings.videoPath = videoPath;
	settings.useHDMIForAudio = true; //default
	settings.enableTexture = true;	//default
	settings.enableLooping = true; //default
	
	
	
	if (settings.enableTexture)
	{
		doShader = true;
		if (doShader) 
		{
			ofEnableAlphaBlending();
			
			shader.load("PostProcessing.vert", "PostProcessing.frag", "");
			
			fbo.allocate(ofGetWidth(), ofGetHeight());
			fbo.begin();
			ofClear(0, 0, 0, 0);
			fbo.end();
			
		}
	}
	
	
	omxPlayer.setup(settings);
	
}
Example #5
0
//--------------------------------------------------------------
void ofApp::setup()
{
	ofSetLogLevel(OF_LOG_VERBOSE);
	string videoPath = ofToDataPath("../../../video/Timecoded_Big_bunny_1.mov", true);

	
	ofDirectory currentVideoDirectory(ofToDataPath("/home/pi/videos/current", true));
	if (currentVideoDirectory.exists()) 
	{
		currentVideoDirectory.listDir();
		currentVideoDirectory.sort();
		vector<ofFile> files = currentVideoDirectory.getFiles();
		if (files.size()>0) 
		{
			videoPath = files[0].path();
		}		
	}
		
	//Somewhat like ofFboSettings we may have a lot of options so this is the current model
	ofxOMXPlayerSettings settings;
	settings.videoPath = videoPath;
	settings.useHDMIForAudio	= true;		//default true
	settings.enableTexture		= true;		//default true
	settings.enableLooping		= true;		//default true
	settings.enableAudio		= true;		//default true, save resources by disabling
	//settings.doFlipTexture = true;		//default false
	
	if (!settings.enableTexture) 
	{
		/*
		 We have the option to pass in a rectangle
		 to be used for a non-textured player to use (as opposed to the default full screen)
		 */
        
        settings.directDisplayOptions.drawRectangle.x = 440;
        settings.directDisplayOptions.drawRectangle.y = 200;
		settings.directDisplayOptions.drawRectangle.width = 400;
		settings.directDisplayOptions.drawRectangle.height = 300;
		
	}
	
	
	//so either pass in the settings
	omxPlayer.setup(settings);
	
	consoleListener.setup(this);
   
    
}
Example #6
0
//--------------------------------------------------------------
void ofApp::setup()
{	
	ofDirectory currentVideoDirectory(ofToDataPath("../../../video", true));
	if (currentVideoDirectory.exists()) 
	{
		currentVideoDirectory.listDir();
		vector<ofFile> files = currentVideoDirectory.getFiles();
		
		
		for (int i=0; i<files.size(); i++) 
		{
			ofxOMXPlayerSettings settings;
			settings.videoPath = files[i].path();
			settings.useHDMIForAudio = true;	//default true
			settings.enableLooping = true;		//default true
			settings.enableAudio = true;		//default true, save resources by disabling
			settings.enableTexture = false;		//default true
			if (!settings.enableTexture) 
			{
				/*
				 We have the option to pass in a rectangle
				 to be used for a non-textured player to use (as opposed to the default full screen)
				 */
                
                settings.directDisplayOptions.drawRectangle.x = 40+(400*i);
                settings.directDisplayOptions.drawRectangle.y = 200;
                
				settings.directDisplayOptions.drawRectangle.width = 400;
				settings.directDisplayOptions.drawRectangle.height = 300;
				
				
			}
			
			ofxOMXPlayer* player = new ofxOMXPlayer();
			player->setup(settings);
			omxPlayers.push_back(player);
		}
    }else{
        ofLogError() << "currentVideoDirectory: " << currentVideoDirectory.path() << " MISSING";
        
        
    }

}
void VideoPlayerApp::loadRandomVideo()
{
    string videoPath = "";
    ofDirectory currentVideoDirectory(ofToDataPath("videos", true));
    if (currentVideoDirectory.exists())
    {
        currentVideoDirectory.listDir();
        vector<ofFile> files = currentVideoDirectory.getFiles();
        if(files.size()>0)
        {
            if(files.size()==1)
            {
                videoPath = files[0].path();
            }else
            {
                videoPath = files[ofRandom(files.size())].path();
            }
        }
    }
    loadVideo(videoPath);
    
}