Re: [pygame] Only first call to Sound.play() is working

2018-04-22 Thread Avi Yaar
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 
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
>


[pygame] Only first call to Sound.play() is working

2018-04-19 Thread Avi Yaar
Hello,

Sorry for the potentially silly question, but I have an ~2 second sound 
file that I want to play twice with a specific time delay between each time 
(time delay is longer than the length of the sound file). 

The sound plays once, but for some reason the second call to .play() is not 
producing any sound.

My script is basically:

import time
import pygame

pygame.mixer.init()
sound = pygame.mixer.Sound("my_sound_file.wav")
sound.play()
time.sleep(10)
sound.play()

I tried looking in the docs at https://www.pygame.org/docs/ref/mixer.html, 
but couldn't find anything that addresses this. 

Thanks for your help!
Avi