URL of experiment: Exp0Practice-ps-morrison-R2 [PsychoPy]
Hello,
I have been having trouble trying to get a previously working experiment to work properly on Pavlovia. Everything works except for the pause/play function and I believe it has something to do with the translation from Python to Javascript.
Here is my original python script that was placed under ‘Each Frame’:
from psychopy import prefs
prefs.hardware['audioLib'] = ['sounddevice']
videopath = r'.\GregTed.mp4'
videopath = os.path.join(os.getcwd(), videopath)
if not os.path.exists(videopath):
raise RuntimeError("Video File could not be found:" + videopath)
# Check for action keys.....
for key in event.getKeys():
if key in ['escape', ]:
win.close()
core.quit()
elif key in ['p']:
if mov.status == PLAYING:
print('PAUSING')
polygon.setAutoDraw(True)
mov.pause()
win.flip()
elif mov.status == PAUSED:
print('UN-PAUSING')
mov.play()
polygon.setAutoDraw(False)
Here is how PsychoPy translates it when I use ‘Auto → JS’:
import {prefs} from 'psychopy';
var _pj;
var videopath;
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);
prefs.hardware["audioLib"] = ["sounddevice"];
videopath = ".\\GregTed.mp4";
videopath = os.path.join(os.getcwd(), videopath);
if ((! os.path.exists(videopath))) {
throw new RuntimeError(("Video File could not be found:" + videopath));
}
for (var key, _pj_c = 0, _pj_a = psychoJS.eventManager.getKeys(), _pj_b = _pj_a.length; (_pj_c < _pj_b); _pj_c += 1) {
key = _pj_a[_pj_c];
if (_pj.in_es6(key, ["escape"])) {
psychoJS.window.close();
core.quit();
} else {
if (_pj.in_es6(key, ["p"])) {
if ((mov.status === PLAYING)) {
console.log("PAUSING");
polygon.setAutoDraw(true);
mov.pause();
psychoJS.window.flip();
} else {
if ((mov.status === PAUSED)) {
console.log("UN-PAUSING");
mov.play();
polygon.setAutoDraw(false);
}
}
}
}
}
Any insight on how to fix this issue would be much appreciated!