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

Re: [pygame] duration of song



On 7/14/07, Dave LeCompte (really) <dave@xxxxxxxxxxxx> wrote:
"Ian Mallett" <geometrian@xxxxxxxxx> wrote:

> On 7/13/07, Jason Coggins <jcoggins828@xxxxxxxxxxx> wrote:
>>
>> Actually I was thinking of using the length of the music played as a
>> variable in the program.

> my_sound = pygame.mixer.sound([filename])
> number_of_seconds_long = my_sound.get_length()

That works for OGG and WAV sounds, but does not work for other music
files, like MP3, MOD, and MIDI, right?

Oh, opps.  You're probably right.  I'm curious now, why don't you know the length of the file?

The only thing I can think of is:
- play the music through pygame.mixer.music.play ()
- monitor the playback time with pygame.mixer.music.get_pos()
- when pygame.mixer.music.get_busy() returns False, you know how long the
music file was. If it helps, you'll know for next time.

That's probably not very helpful, either.


Which file format are you using for your music? Perhaps there is another
Python library that you can use to get the run length of your file.

-Dave LeCompte