How to play multi videos by name continuously?

I am having problems with videos.
I am trying to play several videos by name.
Just play one movie at one time and the play the first movie after finished the final movie.
I modified dirListExample code for videos.

This is my testApp.cpp code.

  
  
#include "testApp.h"  
  
//--------------------------------------------------------------  
void testApp::setup(){  
  
    DIR.setVerbose(false);  
    nVideos = DIR.listDir("movies");  
 	videos = new ofVideoPlayer[nVideos];  
   
    for(int i = 0; i < nVideos; i++){  
		videos[i].loadMovie(DIR.getPath(i));  
		videos[i].play();  
    }  
	  
    currentVideo = 0;  
    ofBackground(255,255,255);  
  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
	videos[currentVideo].idleMovie();  
	if(videos[currentVideo].getIsMovieDone()){  
		if (currentVideo == nVideos){  
		    currentVideo = 0;  
		}else{  
		currentVideo++;  
		}	  
	}  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
	videos[currentVideo].setLoopState(OF_LOOP_NONE);  
	  
      if (nVideos > 0){  
        ofSetColor(0xffffff);  
        ofSetColor(0x999999);  
	videos[currentVideo].draw(0,0);  
	}	  
	  
}  
  

It works, but after finished playing final movie, it doesn’t go back to the first movie.

Someone can help me?

try changing

  
if (currentVideo == nVideos){  

to

  
  
if (currentVideo == nVideos-1){  
  

since your array is initialized to a length of nVideos and you start at 0, the last video will then be nVideos-1.

thank you for reply, but it doesn’t work.

when I put this code for test at keypressed

  
  
void testApp::keyPressed  (int key){  
    if (nVideos > 0){  
        currentVideo++;  
        currentVideo %= nVideos ;  
    }  
}  
  
  

it works perfect. Whenever I pressed key, next video played.
but when I put this code to update it doesn’t work.

  
  
void testApp::update(){  
	videos[currentVideo].idleMovie();  
	  
	if(videos[currentVideo].getIsMovieDone()){  
	     currentVideo++;  
             currentVideo %= nVideos ;  
	}  
}  
  

I also try to this code.

  
  
void testApp::update(){  
	videos[currentVideo].idleMovie();  
	  
	if(videos[currentVideo].getIsMovieDone()){  
		if (currentVideo == nVideos-1){  
			currentVideo = 0;  
		}else{  
		currentVideo++;  
		}  
	}  
}  
  

all of the code work only one time, after finished last video, all of the videos start blinking at the same time.

I set setLoopState to NONE for go to next video, is it have a problem looping all of the videos?

Try putting a trace on the getIsMovieDone property of the currentMovie…is it just returning true continuously after it finishes the first time?

Try resetting the frame to 0. Or calling firstFrame() on the movie once it has finished.

I also find using setPaused(true/false) quite good…

M