psychopy.org | Reference | Downloads | Github

Pause and unpause function that resumes trial where it left off

gligalab_tactors_oddball.psyexp (27.4 KB)

I’ve created an oddball paradigm for an infant study. Infants watch a 10 minute video clip of Fantasia cartoon and during it they receive auditory beep pairs or single beeps. Infants can get easily distracted so we’d like to add a pause function that can pause study and resume from the point it was stopped. The experiment initially was 6 trials of repeated 40s clips and I managed to get a pause function (with the help of psychopy community) that restarts the trial when unpausing. However, now we decided to use a continuous video and trial lasting 10 mins and I am not sure how to do bold.

I’ve attached experiment file in the thread. Any direction or examples on how to do this would be super appreciated. This is the final bit left to get the experiment live…

bump! :slight_smile:

It should be possible to use .pause()

Hello @wakecarter . I’ve tried this code but nothing happens when i press space

for key in event.getKeys():
    if key in ['escape', 'q']:
        win.close()
        core.quit()
    elif key in ['space']:
        # To pause the movie while it is playing....
        if fantasia.status == PLAYING:
            print('PAUSING')
            fantasia.pause()
        elif fantasia.status == PAUSED:
            # To /unpause/ the movie if pause has been called....
            print('UN-PAUSING')
            fantasia.play()

Any idea why? :confused:

Are the print statements working?

Should it be STARTED instead of PLAYING?

Nope. Nothing works :<

Try

keys = event.getKeys():
if 'escape' in keys or 'q' in keys:
        win.close()
        core.quit()
elif 'space' in keys:
        # To pause the movie while it is playing....
        if fantasia.status == PLAYING:
            print('PAUSING')
            fantasia.pause()
       elif fantasia.status == PAUSED:
            # To /unpause/ the movie if pause has been called....
            print('UN-PAUSING')
            fantasia.play()

The keys = event.getKeys(): syntax is wrong

I tried this instead but still nothing:

keys = event.getKeys()

for keys in event.getKeys():
    if 'escape' in keys or 'q' in keys:
        win.close()
        core.quit()
    elif 'space' in keys:
        # To pause the movie while it is playing....
        if fantasia.status == PLAYING:
            print('PAUSING')
            fantasia.pause()
        elif fantasia.status == PAUSED:
            # To /unpause/ the movie if pause has been called....
            print('UN-PAUSING')
            fantasia.play()

Sorry – I failed to remove the colon.

Try

keys = event.getKeys()
if 'escape' in keys or 'q' in keys:
        win.close()
        core.quit()
elif 'space' in keys:
        # To pause the movie while it is playing....
        if fantasia.status == PLAYING:
            print('PAUSING')
            fantasia.pause()
       elif fantasia.status == PAUSED:
            # To /unpause/ the movie if pause has been called....
            print('UN-PAUSING')
            fantasia.play()