pygame newbie problem , please help ?
yaniv
yaniv_vi at yahoo.com
Thu Dec 19 19:44:37 EST 2002
hi
i have a program that need to make sounds . i use the pygame library ,
using a code i have taken from chimp example .
it works o.k. except the first time i run it throught idle , when
there's no sound . i end the program , run it again , and everything
is fine .
what do you think causes this ?
thanks , yaniv
p.s. python is cool tool !
import os,pygame # http://www.pygame.org/
def load_sound(name):
class NoneSound:
def play(self): pass
if not pygame.mixer or not pygame.mixer.get_init():
return NoneSound()
fullname = os.path.join('', name)
try:
sound = pygame.mixer.Sound(fullname)
except pygame.error, message:
print 'Cannot load sound:', fullname
raise SystemExit, message
return sound
if not pygame.mixer: print 'Warning, sound disabled'
sucsess_sound=load_sound('ding.wav')
################################################
sucsess_sound.play()
More information about the Python-list
mailing list