[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] noob questions about creating and playing sounds
On Mon, Jul 20, 2009 at 09:44:45AM -0400, Jerzy Jalocha N wrote:
> Hi, I am starting to experiment with Pygame and how to generate sounds
> and play them back. Here is a code snippet, the full (working) code is
> below.
>
> def play_maxtime(sound, duration):
> sound.play(loops=-1, maxtime=duration)
> pygame.time.delay(duration)
>
> I have a few questions about this:
>
> * 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.
Because without that the program finishes and quits. You would not need
the time.delay if you were using this in a game, since you would be
playing your sounds inside the game's loop.
---
James Paige