psychopy.org | Reference | Downloads | Github

Sound/loops not working

Hello everyone,

I’m trying to do an experiment with background music running all the time.
I’ve tried loops with all four sound engines, but every time the sound was just played ONCE (in other words the arg. loops is not working).
Here is an example of my code:

#########
from psychopy import  core, event
from psychopy import sound
# force quit (anytime): Strg + q|Q
event.globalKeys.clear()
def FQuit():
    print('experiment was manually closed') 
    core.quit()
event.globalKeys.add(key='q', modifiers = ['ctrl'], func=FQuit, name='force quit q')
event.globalKeys.add(key='q', modifiers = ['ctrl','capslock'], func=FQuit, name='force quit Q')
############ background sound (begins with the first instruction)
bgs = sound.Sound('bgm.wav', loops = -1)
bgs.play(loops = -1)
while True:
    pass
#################

I’ve checked the google and this forum, but it seems only I have this problem :frowning:
It would be great if someone here maybe could help me.

Best regards,
PJ