psychopy.org | Reference | Downloads | Github

Pausing movies at their ending in online experiments

Description of the problem:

Some of the movies in my experiment are playing with a lower playback speed than normal. For example, a movie that normally lasts 6 seconds in the experiment it takes it 8.5 seconds to reach the ending. Even though it is something odd, it does not represent a problem for my experiment. However, as in every trial I need to pause the movie at its ending and once it is paused show an image, I cannot rely only clocks to pause the video and show the image.

I figured out that the code in Python below can do the job but I need the experiment to run online.

if myMovie.status == PLAYING and myMovie.getCurrentFrameTime() >= (myMovie.duration - 0.05):
    myMovie.pause()
    myClock = core.Clock()

if myMovie.status == PAUSED:
    if myClock.getTime() >= 1.0 :
        myImage.opacity = 1

However, when I run what I thought would be its JavaScript equivalent online, I get error messages mentioning that:

  • PAUSED is not defined
  • myMovie.getCurrentFrameTime() is not a function

Additionally, logging myMovie.duration returns undefined.

Any ideas on how to make this work in JavaScript?

Thanks in advance

Miguel

I found out how to pause movies at their ending and then trigger some other action using JavaScript :slight_smile:

if (((myMovie.status == STARTED) && (myMovie._movie.currentTime >= (myMovie._movie.duration - 0.1)))) {
    myMovie.pause();
    myClock = new util.Clock;
}

if ((myMovie.status == FINISHED)) {
    if ((myClock.getTime() >= 1.0)) {
        myImage.opacity = 1;
    }
}