psychopy.org | Reference | Downloads | Github

Onset/offset times of the video stimuli are not saving

OS : Windows10
PsychoPy version : v2021.2.3
Standard Standalone? (y/n) y

I am building an online experiment where participants can choose to watch the video till the end or they can press the “space” key to end the routine and therefore stop the video early. I want to save the time when the video started and when/if the “space” key was pressed.

The keyboard component works as expected but I have a problem with the movie component. Despite ticking the option “log onset/offset times” on the movie component, no times are saved in the .csv file.

What did you try to make it work?:
I build another simple experiment from scratch but still no timings saved. Then, following this topic: Onset and offset timestamps for videos
I tried to insert a code component:

Begin Experiment
logged = 0
Each Frame
if logged == 0:
print('TrialStart: '+globalClock.getTime())
logged = 1
elif clip.status == STARTED and logged == 1:
print('Started: '+ int(globalClock.getTime()))
logged = 2
elif clip.status == FINISHED and logged == 2:
print('Stopped: '+ int(globalClock.getTime()))
logged = 3

What specifically went wrong when you tried that?:
With the added code component and when locally, the experiment crashes at the beginning of the video routine. When online, the experiment runs but still no timings are saved for the movie component.

Please can someone help me with this issue? I have no idea how I can fix this.
Thanks!

Hi,

Unfortunately, coding and translating code from PsychoPy (python) to PsychoJS (Java Script) is not straight forward. Code used in one may not work in the other one, or you may need to make some adjustments. Most translations and limitations have been compiled in a document by @wakecarter in this post: PsychoPy Python to Javascript crib sheet

STARTED and FINISHED are the attributes you would use for PsychoJS to check every frame whether a video is playing or the component is no longer in use (the attribute STOPPED takes place when people paused the video but the component is still active), for PsychoPy you need to use PLAYING and STOPPED (in here the component has a special attribute called PAUSE, ).

You can either get the time stamp of the experiment when something in particular occurs by using globalClock.getTime() available both in PsychoJS and PsychoPy, or get the time stamps of the millisecond in the video at which people stopped playing it.

To get the time stamps of the video you need to use myVideo._movie.currentTime in PsychoJS or use myVideo.getCurrentFrameTime() in PsychoPy

For further details please read the documentation and the source code of the component you are interested in.

For PsychoPY you can check the source code here: psychopy.visual.movie — PsychoPy v2021.3

For SPychoJS you cna check the source code here: psychojs/visual_MovieStim.js.html at main · psychopy/psychojs · GitHub

Best,
Miguel

Thank you so much @miguel_santin for your response.
I was hoping that someone may know the way of fixing it in the Builder. I thought the “save onset/offset time” of the movie component is a basic option and it should work, only that I have missed something?

I am really grateful for your comprehensive response and if there is no other way I will need to find the way of getting to grips with the JS code and figure out how to get the timings the way you just described.I am new to coding in python (and never did any JS).

Many thanks, Ula