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

Re: [pygame] Playing OGGs in pygame



Okay, I dropped into command prompt and did the following:

Silvercloud:~/oggbug musenik$ pythonw
Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame.mixer
>>> pygame.mixer.init()
>>> snd = pygame.mixer.Sound('flame.ogg')
>>> snd.play()
<Channel object at 0x520d0>
>>> snd2 = pygame.mixer.Sound('car_door.wav')
>>> snd2.play()
<Channel object at 0x520f0>
>>>

Once again, the ogg sound fails to make any noise, but the wav sound does.

other suggestions?

Keith Nemitz
Mousechief Co.
www.mousechief.com



On Mar 16, 2005, at 3:00 PM, Rene Dudfield wrote:

try importing pygame.mixer by itself, and see what the error is.

import pygame.mixer



On Wed, 16 Mar 2005 13:04:50 -0800, Keith Nemitz <keithn@xxxxxxxxxxx> wrote:
I should have said two other things:

1. This is happening on a Macintosh (mac osx 10.3.8, pygame 1.7, sdl
1.2.8, latest ogg frameworks)

2. The code generates no errors when loading or playing the ogg file.


On Mar 16, 2005, at 1:00 PM, Keith Nemitz wrote:

Okay, this is probably just a side-effect of switching pythons and
upgrading frameworks, but I've got one thing that's killing me. I hope
someone can look at this and say 'hey, dude you just need this file or
do this...'


Basically, I'm trying to play an ogg file as a sound effect. It was
all working a few weeks ago, in fact I shipped an entire python/pygame
game that used oggs for it's music and SFX. But now it's not working.
Here's a minimal example:




class dummysound:
    def play(self): pass

def load_sound(file):
    if not pygame.mixer: return dummysound()
    #file = os.path.join('data', file)
    try:
        sound = pygame.mixer.Sound(file)
        return sound
    except pygame.error:
        print 'Warning, unable to load,', file
    return dummysound()


def main(): global boom_sound

    pygame.init()
    screen = pygame.display.set_mode((640, 480))

    if pygame.mixer and not pygame.mixer.get_init():
        print 'Warning, no sound'
        pygame.mixer = None


boom_sound = load_sound('flame.ogg') #boom_sound = load_sound('car_door.wav') if pygame.mixer: pygame.mixer.music.load('lonTheme.ogg') pygame.mixer.music.play(-1) . . . . boom_sound.play()

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

The music 'lonTheme.ogg ' streams and plays just fine, but the
'flame.ogg' doesn't make a peep. However, if I use 'car_door.wav',
that works when played.

Any thoughts? I could email the full example program to anyone willing
to check it further. (about 300k)




Keith Nemitz
Mousechief Co.
www.mousechief.com