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!