[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] pygame.mixer : playing the same file twice
Hello,
I would like to know why the following code (an example I made from my
bigger not-working code) does not work :
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)
I have a file opened (f), and used twice to create a Sound object,
without closing it betwwen.
When I try it with a wav or ogg file, the first time plays well, but
when it tries to run the last line, I get a
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?
Mickaël