Howdy, Stranger!

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

Supported by

[solved] Pausing video

aemaem
edited April 2015 in OpenSesame

Hello. I'm new to OpenSesame and have little experience coding.

I am using the media_player_vlc plugin to show a video. I would like to allow the participant to pause the video with a keypress (specifically, pressing the spacebar), then un-pause the video on the next keypress. I would like to allow them to pause and un-pause the video as many times as they would like. Though I have seen some posts about pausing sounds (using the sampler and synth items), I'm wondering if it is possible to do this with the media_player_vlc plugin as well?

Thanks!

Comments

  • edited 8:22AM

    Hi,

    What you could do is set the 'Call custom code option' to 'on keypress', and add the following code code:

    print('pause!')
    self.player.pause()
    # Wait for keypress or mouseclick
    while pygame.event.wait().type not in (pygame.KEYDOWN, pygame.MOUSEBUTTONDOWN):
        pass
    print('resume!')
    self.player.pause()
    

    This code will be executed every time that you press a key or click the mouse. It will then pause the player, wait for another key press or mouse click, and then resume the player.

    See also:

    Does that make sense?

    Cheers,
    Sebastiaan

  • aemaem
    edited 8:22AM

    This works perfectly! Thank you!

Sign In or Register to comment.