Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] video files crash

edited June 2015 in OpenSesame

Hi all,

I'm doing an experiment in which I should show participants a series of short videos (2 seconds each).
Participants have to respond pressing one button on the keyboard before the video end. The problem is that if the response is too fast (something like < 1 sec) the experiment crashes.
I've tried both with including the videos in the file pool or referring to them by name.

Is there anything that I can do?

Thanks in advance,

Andrea

Comments

  • edited 11:54AM

    Hi Andrea,

    I'm assuming it works correctly if people respond after that first second? What does the pop-up window say when it crashes?
    And another thing: do people have to be allowed to respond this fast in the first place? If not, then you could also design the experiment in such a way that there is no response possible until after the first second.

    Cheers,

    Josh

  • edited 11:54AM

    Hi Josh,

    Yes, it works correctly if participants respond after the first second! There is no pop-up window, it just stops and doesn't go on....
    Theoretically they could respond at any time, even if I think that in this specific case a response faster than 1 second makes no sense....
    I can design the experiment in such that the response is possible only after the end of the video but I'm afraid that in this way I'll lose a lot of informations... How can I design it to allow response only after the first second of the video (since that every video last 2 seconds)?

    Thanks,

    Andrea

  • edited May 2015

    Hi Andrea,

    Right before the video item, you could place an inline_script where you create a variable that keeps track of time. Normally, this would be as simple as: start_time = self.time(), whereby self.time() is a command that returns the time to a variable called "start_time".

    Now in the video item (do you use media_player_vlc?), there is a window where you can put optional code; this is where you could insert: current_time = self.time() - start_time. Hence, if this code is called 800ms after the inline_script, current_time would be assigned the value 800. We can use this as a means to keep track of time. Be sure to set the "call custom python code" option to "after every frame", so you are indeed continuously keeping track of time.
    The code window would look something like this:

       from openexp.keyboard import keyboard
       my_keyboard = keyboard(exp)
       response, time = my_keyboard.get_key() # collects a key response (or 'none' in  
                                                                          case  nothing was pressed)
    
       current_time = self.time() - start_time
       if current_time > 999 and response != 'none': # i.e., if there was a response
              From here, anything you want to do after your response.
    

    Lastly, the variable start_time you created in your inline_script needs one more thing. If you create a variable like that, it's only 'known' in your inline_scripts, but not yet in other types of items in your experiment (such as your video item). In order to take care of this, you have to add: exp.set('start_time', start_time) after the previous command.
    Now the variable can be called upon anywhere in your experiment. In the video item, you have to insert: start_time = exp.get('start_time'); or simply write current_time = self.time() - exp.get('start_time') directly.

    Let me know how it goes.

    Cheers,

    Josh

  • edited 11:54AM

    Hi Josh!

    First of all, sorry for the very late reply!!!
    I've tried your suggestion and it works! Now the experiment doesn't crash anymore!

    Thank you so much!

    Cheers,
    Andrea

Sign In or Register to comment.