[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Playing mp3 files with the Movie class



I've found out the solution to this problem with some help from the sdl
mailinglist.

The reason SDL behaves the way it does is because it uses DirectSound as the
default under win32 and DirectSound is made to behave this way.

You can make SDL choose what sound library to use by setting the environment
variable SDL_AUDIODRIVER.

So the only thing one needs to do is:

os.environ['SDL_AUDIODRIVER'] = 'waveout'

before using the audio under SDL and it works like a dream.

PS:
It would be nicer if this could be hidden by pygame in some way. I don't
have a clear idea on how to do it in a clean way because pygame should work
cross platform. Maybe a function in the pygame.music module?
(forceWin32BackgroundPlayback or something).

Here are the different sound lib options for SDL_AUDIODRIVER (taken from the
SDL faq):

  Q: How do I choose a specific audio driver?

  A: You can set the environment variable "SDL_AUDIODRIVER" to the name of
the driver you want to use. The drivers available depend on the platform and
SDL compile-time options:


    a.. Linux:
      a.. dsp - (default) Use the OSS API by opening /dev/dsp
      b.. dma - Use the OSS API to perform DMA access on /dev/dsp
      c.. esd - Connect to the ESound audio daemon
    b.. Win32:
      a.. dsound - (default) Use the DirectSound API
      b.. waveout - Use the Win32 MultiMedia API



----- Original Message -----
From: "Pete Shinners" <pete@visionart.com>
To: <pygame-users@seul.org>
Sent: Friday, October 19, 2001 7:14 PM
Subject: Re: [pygame] Playing mp3 files with the Movie class


> Syver Enstad wrote:
>
> > I am using the Movie class for a simple mp3 player, it works very nicely
> > after recompiling the SMPEG.dll to fix the optimization problems under
Vc++.
> >
> > There's one catch though, the sound stops as soon as the pygame window
> > looses focus. Is there anything I can do to avoid this?
>
>
> no. this is how SDL initializes the sound. i'm guessing it would not be
> hard to change SDL so this didn't happen, and i'm sure if someone did it
> would be accepted in the next release of SDL.
>
>
>
>
>
>
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org
>

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org