Moviestim.pause in JS for Pavlovia

URL of experiment: https://pavlovia.org/run/Reuveni/cid

Description of the problem:
I’m designing a task where I show participants a movie with a figure moving in it. I want the movie to pause when a participant presses the space bar but to move to the next trial only after 5 seconds.
I build the experiment using builder and added this code snippet to make it work:
keys = event.getKeys()
if ‘space’ in keys:
figure_move.pause()
print(‘Pause Movie’)
else:
print(‘No Pause’)

On builder it works well, and after changing the translated code in JS to psychoJS.eventManager.getKeys(), when the space bar is pressed the movie ends and it moves on straight to the next trial. This is the code on JS:
var _pj;
function _pj_snippets(container) {
function in_es6(left, right) {
if (((right instanceof Array) || ((typeof right) === “string”))) {
return (right.indexOf(left) > (- 1));
} else {
if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
return right.has(left);
} else {
return (left in right);
}
}
}
container[“in_es6”] = in_es6;
return container;
}
_pj = {};
_pj_snippets(_pj);
let keys = psychoJS.eventManager.getKeys();
if (_pj.in_es6(“space”, keys)) {
figure_move.pause();
console.log(“Pause Movie”);
} else {
console.log(“No Pause”);
}

How can I get my movie to pause without it moving forward to the next trial until the full 5 seconds from the beginning of the movie are over?

Thanks!

Does this link help?

What exactly is going wrong. If the trial isn’t ending when the movie is paused you could add if t> 5: continueRoutine = False

Hi!
Thank You so much for your reply, my problem is not that the movie is not continuing but rather on the contrary when I press the “space” key, the movie ends and it moves to the next trial. Although I want the movie to pause when the “space” key is pressed, I want it the paused movie to remain showing regardless of the “space” key press, for 5 seconds in every trial.

I’ve never tried to pause a movie component but if that bit works I could help with code to sustain the routine for a further 5 seconds.