Black frame after playing video / before reloading new video

Hi there,

I am new to OF and C++, so this is a very beginner question.

I want to show some (~ 4) randomly chosen videos at once and reload new ones when they are finished. I manage to pick them at random, play them and also reload new ones when they are finished, but I can’t get rid of black frames in between two videos. I have tried two approaches and both show problems:

Approach 1:
Draw the ‘ofVideoPlayer’ directly in the ‘draw’ function and in ‘update’ check ‘getIsMovieDone’ in ‘update’. If that evaluates to true, I ‘close’ the current, ‘load’ a new video, and set it to ‘play’. Between the two videos there short is a blank (dark grey of the window) period.

Approach 2 (which I thought should fix it):
Retrieve the pixels of the ofVideoPlayer and convert it to an image and save that in a variable and draw the variable. It checks if there is a new frame and if there isn’t it draws the last saved image in the variable. I thought this would fix it since when no new frame is available it should just draw the previous one. But I am still seeing a black frame in between videos. A bit different from the previous approach this is completely black.

How can I smoothly switch between videos without losing screen?

Cheers,

Claartje

My update and draw function:

//--------------------------------------------------------------
void ofApp::update(){
    for(int i = 0; i<n_videos; i++) {
        if (videos[i].getIsMovieDone()) {
            videos[i].close();
            int r = (int)ofRandom(n_files_dichtbij);
            videos[i].load(dichtbij_dir.getPath(r));
            videos[i].setLoopState(OF_LOOP_NONE);
            videos[i].setVolume(0.0);
            videos[i].play();
        }
        videos[i].update();
    }
}

//--------------------------------------------------------------
void ofApp::draw(){
    
    for(int i = 0; i<n_videos; i++) {
        int row = (int) i / 2;
        int col = i % 2;
        int col_width = ofGetWidth()/2;
        int row_height = ofGetHeight()/2;
        
        videos[i].getCurrentFrame();
        
        if (videos[i].isFrameNew()){
            ofPixels pix = videos[i].getPixels();
            if (pix.isAllocated()) {
                videos_frames[i].setFromPixels(pix);
            }
        }
        
        videos_frames[i].draw(col*col_width, row*row_height, col_width, row_height);

    }