You could consider polling the mixer until the sound stops so you can
avoid hardcoding the time to wait until exit/

https://www.pygame.org/docs/ref/mixer.html#pygame.mixer.get_busy

On Sun, Apr 22, 2018 at 10:07 AM, Avi Yaar <aviy...@gmail.com> wrote:

> Thanks Greg and Pablo for the advice. It turned out to be what Greg
> mentioned, that the second call to play() wasn't making any sound because
> the script terminated immediately after. Adding a second time.sleep(10)
> solved the problem.
>
> Thanks again!
> Avi
>
> On Fri, Apr 20, 2018 at 2:15 AM Greg Ewing <greg.ew...@canterbury.ac.nz>
> wrote:
>
>> Pablo Moleri wrote:
>> >     import time
>> >     import pygame
>> >
>> >     pygame.mixer.init()
>> >     sound = pygame.mixer.Sound("my_sound_file.wav")
>> >     sound.play()
>> >     time.sleep(10)
>> >     sound.play()
>>
>> If that's you're entire program, I'd say it's finishing before
>> the second sound gets a chance to play. The sound.play() call
>> only *starts* the sound playing, it doesn't wait for it to
>> finish.
>>
>> Try putting another time.sleep(10) after the second play.
>>
>> --
>> Greg
>>
>

Reply via email to