psychopy.org | Reference | Downloads | Github

Movie does not play across trials

I have 10 trials and two conditions (randomized across the trials) that consist of playing either an optic flow mp4 movie or a random flow mp4 movie. To load and play the mp4 I used visual.MovieStim3

nBlocks = 4
nTrials = 10

nb_conditions = np.arange(1,3)                            # We have two conditions : Optic flow and Random flow

conditions = nb_conditions.repeat(nTrials/2)           # 5 times condition_1 and 5 times condition_2

conditions_rand = np.random.permutation(nb_conditions)   # Randomize the order of the conditions

# Load optic flow and random flow movies

optic_flow_movie    = visual.MovieStim3(win, 'optic_flow.mp4')
random_flow_movie   = visual.MovieStim3(win, 'random_flow.mp4')


# iterate through trials and play movies 

for trialcount in range(nTrials):

    for Nframes in range(700):
        
        if conditions_rand[trialcount] == 1:
            optic_flow_movie.draw()


        elif conditions_rand[trialcount] == 2:
            random_flow_movie.draw()

        win.flip()


win.close()

It starts playing the first video on the conditions_rand array, then at a random interval of time, it shows a second video and then the screen is black again for a long time as it freezes. Because it doesn’t throw any error, I have no idea why it is behaving this way. Your help would be highly appreciated thanks !!