psychopy.org | Reference | Downloads | Github

Mov.stop error with MovieStim

Hello,

I’m working on an experiment that will record eye tracking data during three movie clips. The movie clips are being presented with MovieStim.

I would like to allow the experimenter to press “escape” during the clip to end it early and proceed to the next clip.

However when I run it with my current code, the 1st clip (which has sound) continues to play sound throughout the other two clips and make the video clips choppy and sometimes freeze.

I’ve tried to add mov.stop() into my ‘break while’ loop but I get the error: AttributeError: ‘ManagedSoundPlayer’ object has no attribute ‘stop’.

I am using PsychoPy 1.86.6 on a Windows 7 64

I would appreciate your help!


# Initialise a PsychoPy MovieStim
mov = MovieStim(win, 'Experiment.mp4',size=[1920,1080], flipVert=False)

# Run for the duration of the video
while mov.status != visual.FINISHED:

    # Fill the Display with the Screen. The right
    # frame from the video will automatically
    # be selected by PsychoPy.
    disp.fill(movscr)
    # Show the Display, and record its onset
    t1 = disp.show()
    # Log the screen flip.
    tracker.log('FLIP; time=%d' % (t1))
    # Check if the Escape key was pressed.
    key, presstime = kb.get_key(keylist=['Escape', 'escape'], timeout=1, flush=False)
    if key in ['Escape', 'escape']:
        # Break the while loop.
        tracker.log('ESCAPE; time=%d' % (presstime))
        mov.stop()
        break

# Initialise a PsychoPy MovieStim
mov = MovieStim(win, 'Resting_somesound.mp4',size=[1920,1080], flipVert=False)


# Run for the duration of the video
while mov.status != visual.FINISHED:

    # Fill the Display with the Screen. The right
    # frame from the video will automatically
    # be selected by PsychoPy.
    disp.fill(movscr)
    # Show the Display, and record its onset
    t1 = disp.show()
    # Log the screen flip.
    tracker.log('FLIP; time=%d' % (t1))
    # Check if the Escape key was pressed.
    key, presstime = kb.get_key(keylist=['Escape', 'escape'], timeout=1, flush=False)
    if key in ['Escape', 'escape']:
        # Break the while loop.
        mov.stop()
        tracker.log('ESCAPE; time=%d' % (presstime))
        break


# Initialise a PsychoPy MovieStim
mov = MovieStim(win, 'VPCstim3.m4v',size=[1920,1080], flipVert=False)


# Run for the duration of the video
while mov.status != visual.FINISHED:

    # Fill the Display with the Screen. The right
    # frame from the video will automatically
    # be selected by PsychoPy.
    disp.fill(movscr)
    # Show the Display, and record its onset
    t1 = disp.show()
    # Log the screen flip.
    tracker.log('FLIP; time=%d' % (t1))
    # Check if the Escape key was pressed.
    key, presstime = kb.get_key(keylist=['Escape', 'escape'], timeout=1, flush=False)
    if key in ['Escape', 'escape']:
        # Break the while loop.
        tracker.log('ESCAPE; time=%d' % (presstime))
        mov.stop()
        break

i.e. try one of the other movie stim backends (2 or 3) to see if this sound issue is improved.

On unrelated performance matters, it might be worth instantiating your three movie stimuli in advance (it can take a while to create each one, leading to delays between each one). Your code to play them seems to be identical, so this could be rolled into a function, which would make your code more concise but more importantly, more maintainable.

e.g.

movies = []
for movie_filename in ['Experiment.mp4', 'Resting_somesound.mp4', 'VPCstim3.m4v']:
    movies.append(MovieStim3(win, movie_filename, size=[1920,1080], flipVert=False))

for movie in movies:
    your_movie_playing_function(movie)

Thanks, Michael.

I am trying to use Moviestim3, however when I try to run it I get the AttributeError: ‘module’ object has no attribute ‘MovieStim3’. Is it possible that I downloaded the wrong version of psychopy through anaconda? Any remedies for this?

Thanks again,
Annie

Sorry, if that class hasn’t been explicitly imported but the visual library has, then should be referred to as visual.MovieStim3()

Hi Michael,

I really appreciate your help.

Yes, I was referring to it with visual.MovieStim3(). However, I seem to be missing the Movie3.py file in psychopy’s visual folder (I only have Movie.py and Movie2.py).

Thanks,
Annie

Hi Michael,

I downloaded the most updated version of psychopy and use MovieStim3() instead of MovieStim(). I also changed my script to be in the form of a loop, as you suggested. Now I do not have an issue with the videos lagging, however, I’m still having a problem with the music from the first clip continuing to play even after I escape out of the loop.

Thanks for you help

Hi, I guess I’m running into the same problem right now (video doesn’t stop playing with next stimulus despite “Force end of routine”). Has anyone found a solution, yet?