Hi Clare,

    I still think it is the same problem as before. The get_busy is only busy 
when the file is playing. You have delayed it to allow the file to Queue in and 
that has fixed it. If your hard drive is slow that would cause it. Most things 
on the screen will not become active until the screen is active and that to is 
part of the issue. Whether threading is an issue, which allows somethings to 
move on while other things are still stuck in the mud has its problems...

    Besides loading the initial package, load all the other packages. I am not 
sure, but I think some of the other packages have a better mixer in it.

    You may just have a timing issue between machines that is being caught on 
an accumulation of issues. That may cause a problem in cross platform 
compatibility, but the get_busy is only active while a file is playing. It must 
be playing first for it to work. If not, you will just run through that while 
statement as if nothing ever played. The reason why putting a delay in has 
fixed the issue. You allowed the file to actually start playing so the busy is 
busy!

        Bruce


I did a little more testing:

OS: Windows XP
Pygame: I installed v1.7.1 for Win32 and Python 2.5
(http://www.pygame.org/ftp/pygame-1.7.1release.win32-py2.5.exe)

I've reproduced the problem on one other WinXP machine with the same
Pygame release, but the problem doesn't occur on my WinXP machine at
home (the sound plays just fine without pygame.mixer.init).

I've been able to determine that pygame.mixer.get_busy() isn't failing,
simply by replacing "pass" with print "Hello".

Calling pygame.mixer.pre_init() instead of pygame.mixer.init doesn't get
play any sound.

*But* sound will play without pygame.mixer.init if I call
pygame.display.set_mode AND put a time delay between loading the sound
and playing it:

------------------------------------------------------
import pygame

pygame.init()
screen = pygame.display.set_mode((500,500)) 

sound = pygame.mixer.Sound("dog.wav")
pygame.time.delay(1000)
sound.play()
while pygame.mixer.get_busy():
pass
------------------------------------------------------

A few questions this brings up:
* Why does setting the display make a difference, and why does this fix
the problem of having to call pygame.mixer.init first?
* Why does it take too long to load the sound, such that it won't play
if I call it immediately? And why does calling pygame.mixer.init first
make this problem go away?

-- Clare Richardson

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Clare Richardson
Sent: Wednesday, October 10, 2007 2:55 PM
To: pygame-users@seul.org
Subject: [pygame] pygame.init before pygame.mixer.init?

I writing a program to simply play one sound (see below for the code),
and came across some interesting behavior.  If I call pygame.init()
before pygame.mixer.init(), I don't hear any sound playing.  However if
I call pygame.init *after* pygame.mixer.init (as below), the sound will
play.

Is this a known behavior?  What's causing the problem?  I understand
that I don't need pygame.init to just play a sound, but I don't think it
should matter if I call it.

Thanks!
Clare Richardson

-------------------------------------------

import pygame

pygame.mixer.init()
pygame.init()

sound = pygame.mixer.Sound("bark.wav")
sound.play()

while pygame.mixer.get_busy():
    pass

pygame.mixer.quit()


Reply via email to