dumb little mp3 jukebox
Will Ware
wware at world.std.com
Wed Aug 30 00:38:10 EDT 2000
#!/usr/bin/python
"""Randomizing MP3 Jukebox
Play your MP3 files in random order until you get sick of them. Works
on RedHat 62. Close this window to quit at the end of the current
tune. To quit immediately, close this window, then type control-C in
the xterm."""
import random, os, sys, string, Tkinter, popen2
class Jukebox(Tkinter.Tk):
def __init__(self, doc=string.split(__doc__, "\n")):
Tkinter.Tk.__init__(self)
self.scanMp3s()
self.title(doc.pop(0))
msg = Tkinter.Message(self, width="6i", text=string.join(doc))
msg.pack(side=Tkinter.TOP)
self.tuneName = Tkinter.StringVar("")
msg2 = Tkinter.Message(self, width="6i",
textvariable=self.tuneName)
msg2.pack(side=Tkinter.BOTTOM)
for x in ['<Visibility>', '<Expose>']:
def f(event,x=x,self=self):
#print x
self.update()
self.bind(x, f)
os.system('touch tmpfile')
self.after(100, self.newTune)
self.mainloop()
def scanMp3s(self):
P = os.popen('find . -name "*.mp3"')
self.files = [ ]
for L in P.readlines():
self.files.append(L[:-1])
P.close()
def newTune(self):
f = random.choice(self.files)
self.tuneName.set(f)
self.update()
cmd = 'mpg123 "' + f + '" >/dev/null 2>&1'
os.system(cmd)
self.after(100, self.newTune)
Jukebox()
--
# - - - - - - - - - - - - - - - - - - - - - - - -
# Resistance is futile. Capacitance is efficacious.
# Will Ware email: wware @ world.std.com
More information about the Python-list
mailing list