[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Re: pygame.mixer : playing the same file twice



Mickaël Leduque schrieb:
> import pygame.mixer
> import sys
> 
> pygame.mixer.init()
> f=open(sys.argv[1],'rb')
> snd=pygame.mixer.Sound(f)
> snd.play()
> while pygame.mixer.get_busy():
>     pass
> snd=None
> snd=pygame.mixer.Sound(f)
> 
> [...]
> Traceback (most recent call last):
>   File "test_pyg.py", line 11, in ?
>     snd=pygame.mixer.Sound(f)
> pygame.error: Unrecognized sound file type
> 
> Shouldn't it work?

You need to rewind the file with 'f.seek(0)' after the first playback. The
'snd=None' line is superfluous.

Chris