problems with latest ofVideoPlayer on mac

I’m using the current latest from SVN (almost same as the 573 version I think) and am having problems with the video player.

I have this code on a ‘play’ key:

  
  
logoVideo.setPosition(0);  
logoVideo.setLoopState(OF_LOOP_NONE);			  
logoVideo.play();  

and this code on ‘stop’ key:

  
logoVideo.stop();  

if I press the play key, the video plays as normal, but keeps looping forever, ignoring the LOOP_NONE flag. If I then press the stop key, the video stops, but when I press play again it just won’t start. Am I doing something wrong? is this a bug?

Has no one else had this? I"ve simplified my app to the barebones below and just cannot get it to work!

Two main problems:

  1. setLoopState(OF_LOOP_NONE); does not work (video keeps looping)
  2. once I stop the video I cannot start it again. The strange thing is, the video.getPosition() is increasing, but nothing is shown onscreen
  
  
//--------------------------------------------------------------  
void testApp::setup() {  
	ofBackground(0, 0, 0);  
	video.loadMovie("testVid.mov");  
}  
  
  
//--------------------------------------------------------------  
void testApp::draw() {  
	ofSetColor(255, 255, 255);  
	video.draw(0, 0, ofGetWidth(), ofGetHeight());  
	  
	ofSetColor(0, 0, 0);  
	ofDrawBitmapString("Video pos: " + ofToString(video.getPosition()) + "\n" + "Video is done: " + ofToString(video.getIsMovieDone()), 30, 30);  
	ofDrawFPS();  
}  
  
//--------------------------------------------------------------  
void testApp::keyPressed  (int key){   
	switch(key) {  
		case 'f':  
			ofToggleFullscreen();  
			break;  
		case 'q':  
			video.setPosition(0);  
			video.setLoopState(OF_LOOP_NONE);			  
			video.play();  
			printf("PLAY\n");  
			break;  
		case 'w':  
			video.stop();  
			printf("STOP\n");  
			break;  
	}  
}  
  

sorry, but in your shell, are you calling idleMovie() in update()
this would explain why you are not seeing pixel updates…

am checking this now…

  • z

sorry there is a bug in play(), which calls start(), which over-rides the loop state. will take a look at that logic. For now, if you do this, it should work:

  
  
	fingerMovie.play();  
	fingerMovie.setLoopState(OF_LOOP_NONE);   
  

instead of:

  
  
	fingerMovie.setLoopState(OF_LOOP_NONE);   
        fingerMovie.play();  
  

that fixes the loop state issue for me, but the other problem I’m having trouble to recreate…

ps, for me, this code works fine with the 0.0573 movie player example, can start and stop + OF_LOOP_NONE works as advertised. I will take a look at fixing that logic tho, since you’d want to be able to call setLoopState at any time.

  
  
//--------------------------------------------------------------  
void testApp::setup(){	   
	ofBackground(255,255,255);	  
	fingerMovie.loadMovie("movies/fingers.mov");  
	fingerMovie.play();  
	fingerMovie.setLoopState(OF_LOOP_NONE);   
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
	fingerMovie.idleMovie();  
}  
  
void testApp::draw() {   
	ofSetColor(255, 255, 255);   
	fingerMovie.draw(0, 0, ofGetWidth(), ofGetHeight());   
	ofSetColor(0, 0, 0);   
	ofDrawBitmapString("Video pos: " + ofToString(fingerMovie.getPosition()) + "\n" + "Video is done: " + ofToString(fingerMovie.getIsMovieDone()), 30, 30);   
}   
  
//--------------------------------------------------------------   
void testApp::keyPressed  (int key){   
	switch(key) {   
		case 'f':   
			ofToggleFullscreen();   
			break;   
		case 'q':   
			fingerMovie.setPosition(0);   
			fingerMovie.play();   
			fingerMovie.setLoopState(OF_LOOP_NONE);          
			printf("PLAY\n");   
			break;   
		case 'w':   
			fingerMovie.stop();   
			printf("STOP\n");   
			break;   
   }   
}   
  

Hi Zach, thanks for looking into this. Swapping the setLoopMode & Play did fix the looping issue, but I still can’t get the video to play the second time round! My vid is an H264 so tried another one (prores) and get the same thing. I copy/pasted your code exactly into my testApp to make sure theres no spellling mistakes etc. and still the same. I also just put the q,w keys code into the moviePlayerExample, and even there it doesn’t work. So i’m thinking it might be something to do with the current version on SVN?

can I ask you to upload the video and / or the project? with the finger movie (from apps/examples) it works fine.

I don’t think there is any difference between the svn and the 0.0573 version of the video player, but I’ll check.

take care!
zach

Hi Zach, its all here
http://public.memo.tv/moviePlayerExample.zip

This is just the standard movie player example with the q/w keys added in. I’m downloading 00573 as well (the latest one I found, 00573-xcode-fat-withpoco_firmata) to try with that…

works with 00573, so something must be broken on the SVN I guess. Dunno if this is something to be concerned about or not?

ah !!! it’s one line of code that got not copied when the linux side of the videoPlayer was updated (the 0.0573 doesn’t have the linux changes). I’ll get this change into the svn, but for now, I would guess that if you did this:

  
  
void ofVideoPlayer::stop(){  
  
	//--------------------------------------  
	#ifdef OF_VIDEO_PLAYER_QUICKTIME  
	//--------------------------------------  
  
	StopMovie (moviePtr);  
	bPlaying = false;  
	SetMovieActive (moviePtr, false);  
  

ie, add bPlaying= false, it should work fine like the 0.0573 version…

hope that helps! sorry about that…

take care,
zach

Hey Zach, that didn’t fix it but adding bStarted = false did. So I now have

  
  
void ofVideoPlayer::stop(){  
  
	//--------------------------------------  
	#ifdef OF_VIDEO_PLAYER_QUICKTIME  
	//--------------------------------------  
  
	StopMovie (moviePtr);  
	bPlaying = false;   
	SetMovieActive (moviePtr, false);  
	bStarted = false;  
  

and that works. If I remove bPlaying = false it still works, not sure if thats needed or not but i’ve left it in for now…

ah yeah, I missed that line with the diff spacing :slight_smile: you are right, there are two missing lines, and the second one seems to fix it. I’m not sure about the first one, but will take a look at the logic.

glad it’s working now, and thanks for the catch
take care !!

ah yeah, I missed that line with the diff spacing :slight_smile: you are right, there are two missing lines, and the second one seems to fix it. I’m not sure about the first one, but will take a look at the logic.

glad it’s working now, and thanks for the catch
take care !!