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

Re: [pygame] Strange mixer problem



This exact thing was happening to me today. I just put a input() line at the end but the pygame.wait should work just as well 

-Zack

On Mar 7, 2012, at 5:32 PM, Julian Marchant <onpon4@xxxxxxxxx> wrote:

> I could be wrong, but it seems to me like the program is just exiting before the sound has a chance to play in full. Try adding a wait at the end (e.g. pygame.time.wait(2000)).
> 
> --- On Wed, 3/7/12, Danny Campbell <danny.campbell@xxxxxxxxx> wrote:
> 
>> From: Danny Campbell <danny.campbell@xxxxxxxxx>
>> Subject: [pygame] Strange mixer problem
>> To: pygame-users@xxxxxxxx
>> Date: Wednesday, March 7, 2012, 9:56 PM
>> 
>> I am running this on Ubuntu Natty, and I've had this problem
>> on a separate
>> 
>> occasion on a different Natty machine. Basically, in some
>> circumstances, I
>> 
>> can't play a sound with the following code:
>> 
>> 
>> 
>> import pygame.mixer
>> 
>> 
>> 
>> pygame.mixer.init()
>> 
>> pygame.mixer.Sound("1up.wav").play()
>> 
>> 
>> 
>> There will either be a click, or more often, no sound at
>> all. There are no
>> 
>> error messages. I have tried using pygame.mixer.get_init()
>> to check if the
>> 
>> mixer has been properly initialized (which it seems to have
>> been). I've
>> 
>> tried using pygame.mixer.pre_init() to specify certain
>> settings (my sound
>> 
>> files are 22050Hz and 1 channel). This didn't help, either.
>> 
>> 
>> 
>> The strangest and most confusing thing is that it will run
>> just fine in
>> 
>> the Python interactive shell. If I load the Python shell and
>> copy and paste
>> 
>> this exact code into it, I get the expected sound.
>> 
>> 
>> 
>> I can't for the life of me figure out what the difference
>> would be between
>> 
>> the command line and the interactive shell (I've double
>> checked the version
>> 
>> of the shell and the version I'm using from the command
>> line, they are the
>> 
>> same).
>> 
>> 
>> 
>> I'm probably missing something very simple, but I've been
>> pulling my hair
>> 
>> out with this and am not sure how to proceed. :)
>> 
>> 
>> 
>> Please let me know if I should send the sound file in
>> question.
>>