pygame sound command?

Hi all I got the pygame working great for my backdrop music…
But when I try pygame sound I have been getting into a bit of trouble.

Perhaps it is just my syntax,

Here is the script:

import pygame.mixer                                     
pygame.mixer.init()                                             
pygame.mixer.Sound("bonus.ogg")
pygame.mixer.Sound.play()

it tells me:

PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “bonus”, line 7, in <module>
TypeError: descriptor ‘play’ of ‘pygame.mixer.Sound’ object needs an argument
I think I am going to go totally mad, I am so close :smiley:

well, I found this:
http://blenderartists.org/forum/showthread.php?t=34706&highlight=pygame+sound

but the example files are all 404

OK!

I got a solution

The sound file was bonus.ogg

 import pygame.mixer                                     
pygame.mixer.init()                                             
sound = pygame.mixer.Sound('bonus.ogg') 
sound.play()

man I cant believe how simple it was :smiley: I was way off on my first guess.

just for trivia sake here is the background music

import pygame.mixer                                           
import os
pygame.mixer.init()                                              
pygame.mixer.music.load("Music.ogg")    
pygame.mixer.music.play()   

I am so happy! I am going to be able to release a game demo in the near future :smiley:

Thanks for sharing Mmph!

Do you have any other tips for installing it and getting it working. I had a look but haven’t tried it yet. Everything seems to be about earlier versions of blender and python. Any words of advice would be gratefully received.

Hi Larryboy!

Sure I made a new updated package for python 2.5 and the bleeding edge version of pygame.

I also put up some scripts I learned , you can find it here:
http://blenderartists.org/forum/showthread.php?p=974279&posted=1#post974279

have fun!
Pygame totally rocks my demo! I have yet to have a sound cut out on me!