Howdy, Stranger!

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

Supported by

Playing audio sounds during a video after mouseclick

Hey all,

I'm trying to program en experiment where a video is shown. When the participant gets a certain feeling (tingles, experiment related to ASMR), they click the right mouse button. Then they must immediately indicate how intense the feeling is by clicking the left mouse button a few times (more = more intense). After 30 seconds, 1 minute, 1 minute 30 seconds, etc. I want to play a soft sound which indicates to them that they need to indicate the intensity of the feeling again (by clicking the left mouse button). I'm having some trouble with overlaying the sounds over the video. Can anyone help?

Comments

  • Hi,

    What is your current approach? And what is the trouble you are having? I've never tried, but I have the hunch it is a bit tricky to have a video keep on playing while the experiment continues in the background until a sounds is played. The reverse (playing sound, while a video is being started) should be more doable.

    Eduard

  • Hi! Sorry for the extremely slow reaction, I have been quite ill for a while.

    I copied code from another experiment that did something similar, but with a picture instead of video. I want to continue playing the video and have a beep every 30 seconds, but the beep is not inherent in the video (because depending on the mouse click, the beep must come at different times during the video).

    from openexp.keyboard import keyboard
    from openexp.synth import synth
    from openexp.canvas import canvas

    The name of the sketchpad to draw on

    media_player_mpy = 'new_media_player_mpy'

    Allowed keys

    allowed_keys = ['k']

    Timeout

    timeout = 18000

    Create objects

    my_keyboard = keyboard(exp, keylist=allowed_keys, timeout=18000)
    my_synth = synth(exp)
    my_canvas = canvas(exp)

    Collect a response until timeout, show the latest response

    and play a sound everytime that a response is given

    response = 'timeout'
    start_time = self.get('time_%s' % media_player_mpy)
    while self.time()-start_time < timeout:
    key, time = my_keyboard.get_key()
    if key != None:
    response = my_keyboard.to_chr(key)
    my_synth.play()

    Log the response

    exp.set('response', response)

Sign In or Register to comment.