How can I make a movie pause at a certain timestamp without key input?

I’m new to psychopy and am having some problems with displaying movie.

I have a list of timestamps of a movie, and I want to play the movie when the experiment starts, and let it pause at each of the timestamps -> say, for 5 seconds -> and then continue playing till the next timestamp. I want it to pause and play automatically without key input.

Now I’m just trying to let the movie pause after 5 seconds by the code as below, but movie does not even show up…(if I comment out the part after the second while, the movies shows up.):

Thank you!

recallPeriod = True
        while recall_trialClock.getTime() <= recallLength:
            if recallPeriod:
                playback.setAutoDraw(True) #playback is the movieStim
                while playback.status==PLAYING:
                   if playback.getCurrentFrameTime()==5: 
                      playback.pause()
                      playback.setAutoDraw(False)
                      recallPeriod = False
           elif......
  • Where is the call to window.flip() (i.e. to actually display the drawn frames)?
  • Don’t ever test floating point numbers for equality to another value (i.e. if playback.getCurrentFrameTime()==5:). Such tests work for integers, but due to the imprecise representation of floats, they will often fail when compared this way.
  • Do movie.pause() and setAutoDraw(False) duplicate each other?

In essence, I guess a problem with this code is that you end up in an infinite while loop (or at least, a loop that last the duration of the movie). The if playback.getCurrentFrameTime()==5: check will likely never evaluate to True, so the movie won’t ever pause. And inside that loop, there is no call to window.flip(), so you’ll never actually see what is going on.

Thank you! This helped a lot.