
That’s the current song playing on my system. It’ll appear on my blog’s right. Requires XMMS bindings for Ruby and Ruby-GD (I don’t know the links to the websites.)
Ruby code »
#!/usr/local/bin/ruby # # $currsong.rb$ $2005-02-28 23:49$ # $premshree pillai$ # require 'xmms' require 'GD' require 'net/ftp' def do_current_song def ftp_image(image) ftp = Net::FTP.new($server_ftp) ftp.login($server_user, $server_pass) files = ftp.chdir($server_path) ftp.putbinaryfile(image) ftp.close end remote = Xmms::Remote.new song_title = remote.title image = GD::Image.new($image_width, $image_height) white = image.colorResolve(255,255,255) black = image.colorResolve(0,0,0) x = 0 y = 10 (err, brect) = image.stringTTF(black, $font_path, $font_size, $angle, x, y, song_title) if err puts err exit 1 end file = open($file_name, 'wb') image.png file image.destroy file.close ftp_image($file_name) end ## # required stuff ## $file_name = 'curr_song.png' # outputs this file $font_path = '/path/to/some/font' $server_ftp = 'ftp.myserver.com' $server_user = 'foo' $server_pass = 'bar' $server_path = '/path/to/dir' ## # for your pleasure ## $angle = 0 $font_size = 8.0 $image_width = 200 $image_height = 12 do_current_song
Enjoi!
2005-02-28 06:57 pm (UTC)
2005-02-28 07:29 pm (UTC)
Then calls the XMMS library to get the title of the current song.
Calls the GD library to create an image with some text formatting.
Creates a png file out of that image and ftp's it to a server.
Premshree,I didnot look at the rss, but r u displying the current song
and not the current one when u posted the blog?
2005-02-28 07:46 pm (UTC)
Very clever. Neat work, dude.
2005-02-28 07:48 pm (UTC)
and not the current one when u posted the blog?
This is just an annexure to the many panels he has on his blog. Even if he hasn't posted anything on his blog, this part would keep updating whenever this script is running and he's listening to music! :p
2005-02-28 09:00 pm (UTC)
2005-02-28 09:01 pm (UTC)
2005-05-05 01:50 pm (UTC)
An even more innovative hack would be to grab the title and query the CDDA database and grab meta-data info and display that too ... ;/
IAC -- nifty hack, dude! :)
2005-05-05 03:21 pm (UTC)
2005-03-01 08:03 pm (UTC)
Where's all the metal?
2005-03-01 08:05 pm (UTC)