I'm looking for a cross-platform Python library that can play MP3 and OGG and support ALSA or similar [closed]

StackOverflow https://stackoverflow.com/questions/1847022

Question

There are several different audio libraries, however, none of them meet my exact needs:
- It needs to be cross-platform.
- It needs to be able to use the ALSA, PulseAudio or any other common default mixer under Linux.
- It needs to be able to autodetect the sample frequency.
- It needs to be (fairly) simple in usage, if instead someone can give me an extra script that will MAKE it easier for me that's accepted too.
- The only functionality I need is play/pause, seeking is a nice bonus.
- It needs to be able to play MP3 and OGG. No other formats are important to me.

The libraries I've tried so far:
PyGame - doesn't support detecting the song's frequency
PyAudiere - promising, but only loads OSS in Linux, with which I have serious mixing problems
Built-in modules - don't support MP3 and OGG as far as I'm aware
PyMedia - promising, but complicated. Also couldn't find out what mixing devices it uses.
PySonic - relies on a closed-source library.
PyQt4.phonon - promising, but wouldn't play anything. Got the following error:

gst_element_make_from_uri: assertion `gst_uri_is_valid (uri)' failed

Any help on this would be appreciated.

Was it helpful?

Solution

Use gstreamer.


  • It needs to be cross-platform.
  • It needs to be able to use the ALSA, PulseAudio or any other common default mixer under Linux.

Check - From gstreamer website:

GStreamer has been ported to a wide range of operating systems, processors and compilers. This include but are not limited to Linux on i86,PPC, ARM using GCC. Solaris on x86 and SPARC using both GCC and Forte, MacOSX, Microsoft Windows using MS Visual Developer and IBM OS/400.

GStreamer can bridge to other multimedia frameworks in order to reuse existing components (e.g. codecs) and use platform input/output mechanisms:

  • Linux/Unix: OpenMAX-IL (via gst-openmax)
  • Windows: DirectShow
  • MacOS X: QuickTime

  • It needs to be able to autodetect the sample frequency.

Okay.

  • It needs to be (fairly) simple in usage, if instead someone can give me an extra script that will MAKE it easier for me that's accepted too.

Gstreamer has a lot of documentation and examples, and a strong community to give you support.

  • The only functionality I need is play/pause, seeking is a nice bonus.
  • It needs to be able to play MP3 and OGG. No other formats are important to me.

Then those are overwhelmed!

Go get yours!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top