I've been getting annoyed with the awful music playing interfaces available on Linux - when compared with the multiple views of the available tracks that WMP has (which is its only good feature, I must add :). So I've been thinking for some time that I should write something that has a track list viewer with filesystem-, artist- and album-oriented tree displays. I really don't want to have to write C++, which what Noatun (the KDE multimedia player) is written in.
So I've been investigating getting into PyKDE again, which is cool because I really like PyQT and PyKDE (and KDE as a whole, really). Writing a Python-based plugin for Noatun would require Python support in Noatun though, and that's not likely to happen.
In the last couple of days, I've been thinking about it from a different angle. I noticed a submission to PyPI: pymad. It's a Python wrapper around an MP3 playing library. A short search later told me that the Ogg Vorbis people also have Python wrappers. Toby (a friend) has already written the track listing viewer (as a part of an ID3 tag editor project). Adding a play button would be pretty trivial at this point... The code to play an Ogg Vorbis file is:
import ogg.vorbis, ao audiofile = ogg.vorbis.VorbisFile(filename) dev = ao.AudioDevice('oss') while 1: buf = audiofile.read(4096) if buf is None: break dev.play(buf, len(buf))
To play an MP3 file instead, the code is the same except the audiofile is:
import mad . . audiofile = mad.MadFile(filename) . .
We're just plugging the bits together, with some extra high-level logic. That's why I love programming in Python :)