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

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



On Wed, 12 Oct 2005, [ISO-8859-1] Mickaël Leduque wrote:

> 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?


The file has an internal pointer that moves
toward the end of the file as you read. So
the second time around, you're basically
reading an empty file.

You could try using f.seek(0) ...

But why would you do this at all? Why not just 
use the same sound object that you already 
have in memory? :)

Sincerely,
 
Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: michal@xxxxxxxxxx
hosting: http://www.cornerhost.com/
my site: http://www.withoutane.com/
-------------------------------------