Videos are not played multiple times in Pavlovia

Psychopy v 3.1.5
Description of the problem: My experiment has some videos which I would like online participants to see several times across trials. The videos play multiple times when I run the experiment with the Builder (I specified the movies to be “set every repeat”, as discussed here) but for some reason they only play once when I run it in Pavlovia. So basically if the movie is played for a second time, I only see the last frame of the movie, and the only way to continue is by exiting the experiment.

1 Like

I’ve just been digging and it appears that psychojs.visual.MovieStim does have hte necessary reset method implemented. It’s just that we haven’t been making a call to that from the Builder output scripts. You should be able to call this manually yourself using a Code Component. Add this to your Begin Routine code in a code component below the movie itself:

nameOfMyMovie.reset();
1 Like

Mmmmh. I am trying your solution now, @jon, but for some reason it doesn’t seem to be working (I’ve added the code component you suggest as a JS code in the Builder, below my movie, at the beginning of the routine (and tried also at the end of the routing). When running it on Pavlovia, it plays the first time, but then the second time I only see the last frame of the movie…

Ok. Finally I found a solution, using psychojs.visual.MovieStim documentation. For some reason the reset method isn’t working, so instead I added this at the Beginning of the routine:

nameOfMyMovie.play();

And this at the end of the routine:

nameOfMyMovie.stop();

Now the videos replay in Pavlovia :slightly_smiling_face:

2 Likes

Hi ! I having the same problem you described above. I am trying to follow your suggestion adding

nameOfMyMovie.play();

and

nameOfMyMovie.stop();

However, I don’t really know javascript and I am quite confused on where did you add these two line of code. Would you mind clarifying where you added the line of code?

1 Like

Hi @TommasoGhilardi,

The first piece of code, nameOfMyMovie.play(); needs to be added at the Beginning of your routine, in the right panel of the Code component (javascript), as you can see here (replace “box_mov_3” with the name of your movie component):

Same thing with the other piece of code, nameOfMyMovie.stop();, which you need to add at the End of your routine.

Also (not sure if this changes anything) but set your movie component to set at every repeat

2 Likes

Hi,
I’m having a similar issue.
I created a pilot experiment in PsychoPy v2020.1.3 in Windows10. It shows 2 short videos (~2s and ~2MB) for 3 times each.
The videos work perfectly if I run the experiment in PsychoPy but not when I run it with Pavlovia ( Pilot mode). At the second repetition of the video, it shows only the last frame.

What I did was to add in the Code component in the same Routine where the videos are. At the Begin and End Routine I wrote the name of the video column in the Excel file I specified in the trial Properties. Unfortunately, it did not solve the problem.
Do you have some additional suggestions?
Thanks a lot

Hi @mariacarlaMemeo. Not sure why it might not be working, but here are two things you could try:

  • Setting your movie component to set at every repeat .
  • The first code component nameOfMyMovie.play(); needs to be added at the Beginning of the routine, in the right panel (javascript), while the second code component nameOfMyMovie.stop(); needs to be added at the end of that same Routine.
1 Like

Hi!
I’m having the same problem as @mariacarlaMemeo. Two video fragments of 2 seconds should play right after each other. So I have two movie components within the same trial. They are both set to ‘set at every repeat’ and I tried adding the code components for both movie components. If I upload this to Pavlovia, only the first movie plays.
I then tried making two code components (for each movie separately), and tried both the ‘reset’ and ‘stop’, but nothing seems to make it better.

I would really appreciate if someone could help me out.
Thank you very much!

Hi @Mardock,
thx for your reply!
I tried what you suggested one step at a time.
I did set the movie component to set at every repeat and the experiment is working in PsychoPy but not in Pavlovia.
Then, I inserted the custom code at the beginning and the end of the Routine. Here there is a picture of the structure of the whole Routine:
image

At the beginning it was not working even in PsychoPy, because I inserted the nameOfMyMovie.play() and nameOfMyMovie.stop() with Code Type: Auto → JS.
It started working again when I changed it as Code Type: Both.

Unfortunately, none of those are suitable solutions for Pavlovia (I commited and pushed the code from PsychoPy) and I’m still having the same issue.

URL: https://run.pavlovia.org/mmemeo/intentions
Code: Sign in · GitLab

I played a bit with the JS code in PsychoPy Builder and now in Pavlovia I have the following error: TypeError: Show_vid.play is not a function.
I displayed the entire error message in the javascript console in Chrome, below there is the relative picture:

I searched for solutions but I wasn’t able to find anything appropriate.
As far as the error states I thought that I should probably change the Code in which I added Show_vid.play(). Show_vid is the name of the column in the Excel file where the name of videos are written. I tried to edit the code in the following ways:

  • $Show_vid.play() ;
  • $Show_vid.[0].play() ;
  • $Show_vid.get().play() ;
  • $('Pouring_video.mp4')[0].play(); where Pouring_video.mp4 is the explicit name of the video;
  • $('Pouring_video.mp4')get().play();

I tried also all the previous codes without $ at the beginning. But I managed to have always the same error.
Thanks for your help

Ok, problem solved. It was a trivial issue for a beginner as I am.

What I was wrongly inserting in the custom code was the name of the excel file column with the list of the videos.
Instead the correct one is the name of the video ‘instance’ created in Psychopy, e.g. movie_randomized as you can see in the following image.
image

I hope it can help!

Sadly, I still haven’t found a solution. I tried playing around with the combination of multiple code snippets and their placement.
This is where I am now:
image
The first video plays but freezes at the last frame so the second video isn’t visible anymore. After 7 seconds the ‘text_answer’ appears on top of the frozen video.
I made the code snippets based on the information from the previous posts. (with .play(); and .stop(); ).

Maybe somebody knows what I’m doing wrong and/or how I can fix it?
Thank you!

Hi @MyrteVC ,
my final configuration of the routine is this:
image

For me it worked adding only one code component after the video instance (movie_randomized). I’m not sure if it is the case also with the presentation of 2 videos.

1 Like

A note on the video solution to use movie.play() in the code component.
Because this goes in ‘begin routine’, it seems to start the video as soon as the routine starts whether it is onscreen or not - i.e. you may not want it to play until after a 1second fixation. so set it to start at 1, however the video will actually have already been playing for 1 second before it actually appears. This may be the problem that @MyrteVC was having.

This issue has made all my timings completely wrong, and so I hope others see this and don’t make the same mistake

@Mardock thanks a million for solving this problem before I had it, so I could use your solution! However, when using movie.play(); and movie.stop(); at begin routine and end routine, respectively (and I added movie.reset(); right before the movie.play();, which didn’t make anything better or worse), my videos begin to stutter. I mean, they don’t run smoothly anymore, the way they ran before. Does anyone know why that might be? Does the play() use another player than would be used without that line or something like that?

I’m not sure what you mean by not running smoothly. I had an issue where the video started in the wrong place and quickly snapped back to the start - does this describe what you are seeing? To solve it, I just presented a brief (100ms) blank stimulus at the start of the trial which essentially covered the very start of the video, this probably didn’t remove the jitter but covered it so that it wasn’t seen by participants. The other thing would be to see if reducing the size of the video files helps. Sorry I don’t have a more technical solution.

Well, it looks like a bad internet connection in a video chat (without the blur effect). The picture sometimes hitches… it stands still for a short time and then jumps to the correct frame. So, it’s unfortunately not only at the very start of the videos. I’ll try something like a short blank stimulus as you suggested in the beginning, anyhow - maybe it’s some kind of buffering problem… I’ll report when I’ve tried! ^^

UPDATE: didn’t work

Update: I just realized that the problem seems to arise from the window size (runs smoothly on laptop screen and in small-sized browser window on second (large) screen, but hitches in large-sized browser window on large screen) and/or the browser (runs smoothly when small-sized in firefox, but always hitches in chrome) … will look for more appropriate forum posts… cheers

I have the same problem! I have two videos in each trial and text components before the first movie, between the two movies, and after the second movie. The text components are shown on top of the last frame (?) of the movies. The movies also don’t play after I played them once.

I played around with putting the code components before and after each movie, at the beginning and end of the routing, only after each movie, only at the end to stop or reset the movies. Nothing works! Putting movie.play() in beginning of routine screws up the timing of my trial components, .stop() and .reset() don’t seem to do anything.

Does anyone have a solution when using two movies?