[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] pygame.mixer : playing the same file twice
It is standard behavior for most, if not all, languages to do this.
Even if you are not sure you are going to use the sound file, you can
still use the copy you've already loaded into memory. You can
throw it out, overwrite it with a new sound object, it doesn't mind.
As far as file types go, one sanity check is to check the file
extension of the filename you're trying to load. For example, if
filename.split('.')[1]=="mp3":
That might be even faster than loading sound files into memory and destroying the invalid objects.
On 10/11/05, Peter Shinners <
pete@xxxxxxxxxxxx> wrote:On Wed, 2005-10-12 at 01:12 +0200, Mickaël Leduque wrote:
> 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?
When Pygame reads from the file-like objects it does no rewinding or
positioning. It just reads bytes from the stream. This means you can
load images from a lot more than files. You could read from an http
stream, or directly out of a zipped archive.
It could be better implied in the documentation how that works.
Generally in all of Python tools. When something wants to read from a
file-like object it usually only calls the read() method on it. (and
maybe sometimes close())
--
Andrew Ulysses Baker
"failrate"