PsychoJS: How to get a video to play constantly throughout a loop (i.e., not start over every trial)?

Hi! I’m running my experiment off Pavlovia so I’m looking for a solution either in the builder or using PsychoJS code (it works as intended in PsychoPy already).

I’m trying to make a video play constantly throughout repeated trials of a routine. By default, it starts over on every repeat. To give more context, this is a stroop task with a video playing on the side, so I’d like the video to keep playing while the words change.

I found a partial solution…commenting out [ myvid.stop(); ] in my JS code on gitlab seems to do the trick, but then I can’t make any changes in the builder and resync it with Pavlovia, which isn’t ideal. So, is there either a way to:
a) Stop that line from being run via a code component in the builder, or
b) Get the video to play constantly some other way?


Hi @bmross21, were you able to figure this out? Could you send me a link to your repo? Here to help, s.

The principle I would try here is the way I present asynchronous sound files.

  1. Set up the sound component in a routine which ends (in code) before the start time set for the component.

  2. Then start the sound component in code using something like

Thank you! I don’t think I did exactly what you meant, but I was able to get it to work by creating the video object manually and using play() as you said. @sotiri I have it working now, but thanks!

This is what I did to get the video to play continuously through multiple trials of the same routine and even carry over into a different routine:

  1. I created the video component normally and set up the settings (mostly just size/position) as I’d like.
  2. I generated the JS code (File > Export HTML) and copied the MovieStim object creation from it. Mine was:
myvid = new visual.MovieStim({
    win: psychoJS.window,
    name: 'myvid',
    units: 'pix',
    movie: 'myvid.mp4',
    pos: [500, (- 50)],
    size: [210, 586],
    ori: 0.0,
    opacity: 1.0,
    loop: false,
    noAudio: true,
  1. I disabled the video component, then added a code component to the routine and pasted the above code into JS “Begin Experiment.”
  2. I added this to “Begin Routine” since I wanted it to play as soon as the routine started:
  1. To stop the video, I added a code component to the next routine, and in “Begin Routine” I added:

I put it on the next routine instead of “End Routine” since my video is to play during many repetitions of that routine, so it would’ve required extra coding to specify that that code would only be executed on the last repetition/trial of it.

1 Like

Looks good @bmross21, thanks for taking the time to post your solution for the rest of us, cheers, x