Mp3-player written in Clojure using Derby, Swing, Clojure-contrib etc!

69 views
Skip to first unread message

smarf

unread,
May 2, 2009, 6:33:37 PM5/2/09
to Clojure
This is my first major Clojure program and my first major lisp-program
at all.
It unfortuneately has a few bugs. 1 minor where I don't handle an
exception when there is no file chosen when you open a playlist.
The big and annoying one however is that sometimes the player starts
playing 2 songs. I suspect this has something to do with the threading/
polling where I check if the song is complete or not.

I think the code in general is not very pretty. Maybe it is all the
Java interop that makes it look a bit cludgy. The logic is decently
separated but I don't feel all that satisfied with it.

It uses Derby as a database(just for storing basic playing-info(the
only thing it is used for is loading 10most played songs but if you
look in database.clj you can read the database and get the info out to
do something with that). Clojure-contrib's sql lib makes the database
interop very easy.
For the GUI I use Swing and Miglayout and miglayout from Clojure-
contrib which I find very neat.

Start repl with:
C:\clojure>java -cp clojure.jar;C:/clojure/;C:/clojure/classes;C:/
javalibs/miglayout-3.6.2-swing.jar;C:/javalibs/mp3/jl1.0.jar;C:/
Progra~1/Sun/JavaDB/lib/derby.jar;C:/clojure/clojure-contrib.jar;
clojure.lang.Repl
user=> (load-file "C:/clojure/progs/mp3player/mp3player.clj")
#'progs.mp3player.mp3player/compile-player
user=> (progs.mp3player.mp3player/compile-player)
progs.mp3player.mp3player
user=>

here's a python script to run the player once it is compiled:
#!/usr/bin/env python
import subprocess

command = "javaw -cp C:/javalibs/jl1.0.1.jar;C:/javalibs/
miglayout-3.6.2-" + \
"swing.jar;C:/clojure/clojure-contrib.jar;C:/clojure/
clojure.jar;" + \
"C:/Progra~1/Sun/JavaDB/lib/derby.jar;
progs.mp3player.mp3player"

subprocess.Popen(command)



Finally, here is the code:

main:
http://paste.lisp.org/display/79566
guilogic:
http://paste.lisp.org/display/79567
utils:
http://paste.lisp.org/display/79568
database:
http://paste.lisp.org/display/79569
Reply all
Reply to author
Forward
0 new messages