Hi,
[EDIT: I was able to circumvent the issue but I do not consider it a solution, so I am still looking for ideas/suggestions]
I do not seem to be able to stop a sound from playing at the end of the trial and it leaks to the next trial/routine.
I define my sound component using code.
I know the sound_2.status === PsychoJS.Status.STARTED
at the End Routine evaluates as I get PASSED!
printed in the console. Therefore, I do not know why the sound_2.stop();
does not work.
Each Frame:
if (mouse.isPressedIn(bubble) && (sound_2.status === PsychoJS.Status.NOT_STARTED)){
sound_2.tStart = t;
sound_2.frameNStart = frameN;
psychoJS.window.callOnFlip(function(){ sound_2.play(); });
sound_2.status = PsychoJS.Status.STARTED;
}
if (t >= (sound_2.getDuration() + sound_2.tStart) && sound_2.status === PsychoJS.Status.STARTED) {
sound_2.stop();
sound_2.status = PsychoJS.Status.FINISHED;
}
//allow for sound to be played every time the speech bubble is clicked on
if (mouse.isPressedIn(bubble) && (sound_2.status === PsychoJS.Status.FINISHED)){
sound_2.play();
sound_2.tStart = t;
sound_2.frameNStart = frameN;
psychoJS.window.callOnFlip(function(){ sound_2.play(); });
sound_2.status = PsychoJS.Status.STARTED;
};
End Routine
if (sound_2.status === PsychoJS.Status.STARTED) { //if sounds is still being played
console.log("PASSED!");
sound_2.stop();
sound_2.status = PsychoJS.Status.FINISHED;
}
Any help will be much appreciated.
Thanks
Yiannis