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

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



Michal Wallace a écrit :


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) ...

Oh, I thought the player would read from the begining of the file, and so do the seek(0) itself...
Shouldn't that be in the docs?


Say I want to check the file type before sending it to the player. I do a f.read(3) to see any magic number here. And after that, I do a snd=Sound(f), and it doesn't work!
Now that I think about it, I think I came on a bug like that at a time...



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

In my real program, I don't know if that file will be the one used or not. In fact, I didn't see the problem because it would occur only if I played the same file twice (I didn't do it in my tests).



Now that works, thanks! Mickael