ofxOMXPlayer not displaying video


#1

I have gotten my Raspberry pi to display videos using the ofxOMXPlayer addon, however, now I am trying to not display the video at the very beginning, but only display it when an external button that is connected to the GPIO is pressed. I have already set up the GPIO and is working. My problem is that when I press the button it displays a black screen instead of the video. The path to the .mov file is correct, as I have tried inputting an incorrect path and in this case if I press the button nothing happens, so I don’t know why it is not displaying the the video
Here is my .cpp code:

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
	ofSetBackgroundColor(225, 225, 225);
	ofSetCircleResolution(128);
	
	angle = PI / 2;
	x = ofGetWidth() / 2;
	y = ofGetHeight() / 2;
	dialRadius = ofGetWidth() / 10;
	maxRotation = -(1 / sqrt(2));
	handRadius = 2 * dialRadius / 3;
	xHand = 0;
	yHand = 0;
	
	// setup buttons
	gpio17.setup("17");
	gpio22.setup("22");
	gpio10.setup("10");
	gpio17.export_gpio();
	gpio22.export_gpio();
	gpio10.export_gpio();
	gpio17.setdir_gpio("in");
        gpio22.setdir_gpio("in");
        gpio10.setdir_gpio("in");

	ofSetLogLevel(OF_LOG_VERBOSE);
	
	string videoPath = ofToDataPath("/home/pi/openFrameworks/apps/myApps/test/bin/data/forest.mov", true);
	
	//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
	
	
	//so either pass in the settings
	omxPlayer.setup(settings);
	
	//or live with the defaults
	//omxPlayer.loadMovie(videoPath);
}

//--------------------------------------------------------------
void ofApp::update(){
	xHand = x + handRadius * cos(angle);
	yHand = y + handRadius * -sin(angle);
	
	rotateHand();
}

//--------------------------------------------------------------
void ofApp::draw(){
	ofSetColor(0, 0, 0);
	ofNoFill();
	ofDrawCircle(x, y, dialRadius);
	ofDrawLine(x, y, xHand, yHand);
	playVids();
}

//--------------------------------------------------------------
void ofApp::playVids() {
	int w = 800.0;
	int h = 480.0;
	
	gpio10.getval_gpio(state_button3);

	if (state_button3 == "1") {
		videoMode = 1;
	} else {
		videoMode = 0;
	}
	
	switch (videoMode) {
		case 1:
			if(!omxPlayer.isTextureEnabled()) {
				return;
			}
			omxPlayer.draw(0, 0, ofGetWidth(), ofGetHeight());
	}
}

//--------------------------------------------------------------
void ofApp::rotateHand() {
	gpio17.getval_gpio(state_button1);
	gpio22.getval_gpio(state_button2);

	// this fixes noise so that when it reaches max rotation it can still move back
	if (xHand < x && sin(angle) < maxRotation)
		angle -= 0.1;
	else if (xHand > x && sin(angle) < maxRotation)
		angle += 0.1;
		
	// for button presses
	if (state_button1 == "1" && sin(angle) >= maxRotation)
		angle += 0.1;
	else if (state_button2 == "1" && sin(angle) >= maxRotation)
		angle -= 0.1;
		
	usleep(50000);
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){
	/* THIS IS FOR UP AND DOWN ARROW KEYS TO CONTROL ROTATION OF DIAL HAND
	if (xHand < x && sin(angle) < maxRotation)
		angle -= 0.1;
	else if (xHand > x && sin(angle) < maxRotation)
		angle += 0.1;

	if (key == OF_KEY_UP && sin(angle) >= maxRotation)
		angle += 0.1;
	else if (key == OF_KEY_DOWN && sin(angle) >= maxRotation)
		angle -= 0.1;
	*/
}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){

}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){ 

}

The playVids function is what’s creating the black screen after a button press. Any help would be much appreciated!


#2

Figured it out, the ofSetColor function was causing the whole video to go black