ofVideoPlayer looped media, how to detect media has already looped?

Hi all ! When an ofVideoPlayer is playing in loop mode, is there an easy way to know if the media has already reached the end and looped once ?

I mean, without disabling loop mode and looping media myself using getIsMovieDone(). I dunno if looping manually would produce a smooth looping of not…

Thanks !

Hi Tactif, You can detect the number of times the video has looped without handling the looping yourself. Here is one way to do it.

.h

ofVideoPlayer 	fingerMovie;
int loopCount;

in setup:

fingerMovie.load("movies/fingers.mov");
fingerMovie.setLoopState(OF_LOOP_NORMAL);
fingerMovie.play();    
loopCount =0;

in update:

fingerMovie.update();

if(fingerMovie.getTotalNumFrames() == fingerMovie.getCurrentFrame()){
    loopCount++;
    if (loopCount == 1){
        ofLog() << "first loop complete";
    }
    ofLog() << "number of times video has looped: " << loopCount; 
}
1 Like

Clever !!! Thanks a lot !

depending on the framerate of the video/application you might not always get the very last frame although is highly unlikely since the app is usually going to run faster than the video, in any case you can use getIsMovieDone() which should always return true if the player arrived at the end for the next update/draw

1 Like

Ok fine ! Thanks !

Just tried it today, getIsMovieDone() never returns true on a OF_LOOP_NORMAL video media… Is it the expected behaviour ?

no, it should, what platform are you in?

OSX Yosemite (10.10.5) - of 0.9.3

With QT Creator might be a missing/wrong OF_VIDEO_PLAYER_XXX define ?

Just checked
OF_VID_PLAYER_TYPE is defined as ofAVFoundationPlayer