[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] noob questions about creating and playing sounds
>> * Why is it that play_maxtime doesn't work without the time.delay?
>> When I remove the delay line, no sound is played, despite the use of
>> the maxtime argument.
>
> Make sure you aren't calling it repeatedly. I once had a problem like this
> that was solved by not calling the sound repeatedly. What can happen is
> that the auto-channels will get filled with queued sounds, and won't have a
> chance to play before being called again. This may or may not be your
> problem.
Ian, as far as I understand, I am calling it just once in both
methods. I am using the 'loops=-1' argument of play() to hold (or
repeat) the note:
def play_maxtime(sound, duration):
sound.play(loops=-1, maxtime=duration)
pygame.time.delay(duration)
def play_loops(sound, duration):
sound.play(loops=-1)
pygame.time.delay(duration)
sound.stop()
I guess, play() knows ho to do the 'loops' correctly?