MP3-Player in Python?

  • Thread starter Thorsten Pferdekämper
  • Start date
T

Thorsten Pferdekämper

Hi,
I am currently trying to code a little MP3-Player in Python. I do not try to
do all the decoding stuff in Python, I am just looking for a (more or
less...) platform independent way to play MP3s. I also want to display
information like these stored in the ID3-tag and information like the length
in seconds, the scan frequency etc.
So far, I have found the following solutions, but I am not really happy with
all of them:

1. pygame.mixer.music:
Pros: Seems to be very platform independent
Cons: I was not able to get the length in seconds etc.

2. tksnack
Pros: Lots of functionality. Really cool.
Cons: Needs Tkinter to run. (I would like to run this without X in
Linux.)

3. popen mplayer or something like this
Pros: ?
Cons: Don't know how to control volume, position etc.
Dont' know how to close mplayer in Windows...

So far for the MP3 playing stuff.

Concerning the ID3 tags, I have found the id3-py package
(id3-py.sourceforge.net). It worked, but I dislike the automatic saving of
changes on deconstruction. It also causes problems with german umlauts...
It also seems not to support ID3v2.

I also know mmpython, but I do not know how to run this with Windows XP. (It
works fine with Linux...)

So, what do you think?

Regards,
Thorsten
 
J

Joe Francia

:

Concerning the ID3 tags, I have found the id3-py package
(id3-py.sourceforge.net). It worked, but I dislike the automatic saving of
changes on deconstruction. It also causes problems with german umlauts...
It also seems not to support ID3v2.

I don't know about playing them in a platform-independent way, but for
tags, MP3Info from http://www.omniscia.org/~vivake/python/ seems to work
very well. Supports ID3v1, ID3v2 and Unicode, and is OS-agnostic:

#----------------------------------------
import MP3Info
import os
from operator import mod

basedir = '/music/l/liszt'
for song in os.listdir(basedir):
f = file(os.path.join(basedir, song), 'rb')
m = MP3Info.MP3Info(f)
f.close()
dur = '%d:%02d' % (m.mpeg.length/60, mod(m.mpeg.length, 60))
print '[%s] - %s (%s)' % (m.artist, m.title, dur)

#----------------------------------------

Output:
[Leslie Howard] - Totentanz - Phantasie für Pianoforte und Orchester
S126i - Andante - Allegro - Allegro moderato - (3:43)
[Leslie Howard] - Totentanz - Phantasie für Pianoforte und Orchester
S126i - Variation 1 - Allegro moderato - (1:40)
(etc...)

Also, you don't mention Ogg Vorbis, but you may want to do it later:
http://www.andrewchatham.com/pyogg/

Peace,
Joe
 
K

klappnase

Thorsten Pferdekämper said:
Hi,
I am currently trying to code a little MP3-Player in Python. I do not try to
do all the decoding stuff in Python, I am just looking for a (more or
less...) platform independent way to play MP3s. I also want to display
information like these stored in the ID3-tag and information like the length
in seconds, the scan frequency etc.
So far, I have found the following solutions, but I am not really happy with
all of them:

1. pygame.mixer.music:
Pros: Seems to be very platform independent
Cons: I was not able to get the length in seconds etc.

2. tksnack
Pros: Lots of functionality. Really cool.
Cons: Needs Tkinter to run. (I would like to run this without X in
Linux.)
If Tkinter is the only problem you have with snack, you actually can
run it without X:

from Tkinter import Tk
import tkSnack

r = Tk()
r.withdraw()#removes the window from the screen
tkSnack.initializeSnack(r)
etc...

Regards

Michael
 
E

Eric Baker

Thorsten Pferdekämper said:
Hi,
I am currently trying to code a little MP3-Player in Python. I do not try to
do all the decoding stuff in Python, I am just looking for a (more or
less...) platform independent way to play MP3s. I also want to display
information like these stored in the ID3-tag and information like the length
in seconds, the scan frequency etc.
So far, I have found the following solutions, but I am not really happy with
all of them:

1. pygame.mixer.music:
Pros: Seems to be very platform independent
Cons: I was not able to get the length in seconds etc.

2. tksnack
Pros: Lots of functionality. Really cool.
Cons: Needs Tkinter to run. (I would like to run this without X in
Linux.)

3. popen mplayer or something like this
Pros: ?
Cons: Don't know how to control volume, position etc.
Dont' know how to close mplayer in Windows...

So far for the MP3 playing stuff.

Concerning the ID3 tags, I have found the id3-py package
(id3-py.sourceforge.net). It worked, but I dislike the automatic saving of
changes on deconstruction. It also causes problems with german umlauts...
It also seems not to support ID3v2.

I also know mmpython, but I do not know how to run this with Windows XP. (It
works fine with Linux...)

So, what do you think?

Regards,
Thorsten

I tried this under windows, it worked quite well. It will play the files,
you will need other modules for tags and such things.

http://audiere.sourceforge.net/home.php

Audiere is a high-level audio API. It can play Ogg Vorbis, MP3, FLAC,
uncompressed WAV, AIFF, MOD, S3M, XM, and IT files. For audio output,
Audiere supports DirectSound or WinMM in Windows, OSS on Linux and Cygwin,
and SGI AL on IRIX.

Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,283
Latest member
JoannaGrif

Latest Threads

Top