play mp3 files from python

Adam Endicott x at x.com
Sat Oct 25 15:29:02 EDT 2003


I got all excited when iTunes was released for Windows. Then I was 
quickly disappointed when I found out it only works for XP or 2000 (I'm 
out of luck with 98 or ME). So I figured, hey, I've been wanting to write 
my own python player anyway, why not make a PyTunes?

I hit my first stumbling block almost immediately. I can't seem to find 
an easy module that will let me play an mp3 file. I'm sure it must be out 
there, but I can't figure it out (I'm a newbie to all but the most simple 
Python scripts, and I know nothing about audio processing). About an hour 
of searching kept turning up the same couple of things (PyGame and 
mpg123).

PyGame - tried this, and got it working very easily. It played, but 
sounded terrible. I'm using a sample script which I think came from 
c.l.py:

mixer.init(44100)
mixer.music.load(filename)
mixer.music.play()
mixer.music.get_busy()

print "Press enter to quit."
raw_input()

Again, that works, but the sound is absolutely terrible. The file I'm 
using to test gives me the following information in winamp (in case this 
may be the reason).
209kbit (VBR), 7316 frames
44100Hz Joint Stereo
The PyGame documentation in this area seemed pretty sparse to me (as 
someone who doesn't know anything about audio files). Is there a way to 
tweak the sound?

mpg123 - I saw this referenced a number of times, but I don't know how to 
use it. I've never used any C code from Python. Is there a Python wrapper 
for this that I could use? I didn't see one, but I may have missed it.

Sorry for the long post, but my main question is, what's the easiest way 
to play an mp3 file from Python on a windows system? If one of the above 
is my best option, can someone help me with the next step to get it 
working?

Thanks in advance for any help.




More information about the Python-list mailing list