Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best python solution to play ALL kinds of audio on Windows (and Linux)?

I'm trying to write some scripts to play some of my music collection with python. Finding python modules that will play ogg and mp3 is not a problem. However, I'm having repeated failures with aac-encoded m4a files from iTunes (not DRM). pygame's audio machinery doesn't support them, so I tried pymedia:

a = pymedia.player.Player()
a.start()
a.startPlayback("myM4a.m4a", format='aac')

I've tried several versions of the last line of code, including omitting the format argument, changing the files to mp4, etc. mp3's work fine, however.

pymedia even claims to support aac encoded files, but the project appears to have been abandoned anyway.

Is there a good, up to date, solution for playing ALL types of audio in python? What is used by existing python media centers/players?

I should add that I intend to use this primarily on windows, so windows support for the library is a must, but cross-platform would obviously be preferable.

like image 745
cemulate Avatar asked Nov 26 '25 02:11

cemulate


1 Answers

You should look at the gStreamer API. It has plugins for many major audio types, is used by many audio players including Banshee and Rhythmbox and it can run on Linux, Windows and Mac. It has Python bindings as well as bindings for many other languages:

http://gstreamer.freedesktop.org/bindings/

like image 62
djsumdog Avatar answered Nov 28 '25 17:11

djsumdog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!