Vincent Foley
Posts: 512
Nickname: gnuvince
Registered: Apr, 2005
Vincent Foley is a hobbyist Rubyist.
Web-based Xmms control program
Posted: Jul 15, 2005 10:30 PM
This post originated from an RSS feed registered with Ruby Buzz
by Vincent Foley.
Original Post: Web-based Xmms control program
Feed Title: Vincent Foley-Bourgon
Feed URL: http://www.livejournal.com/~gnuvince/data/rss
Feed Description: Vincent Foley-Bourgon - LiveJournal.com
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Vincent Foley
Latest Posts From Vincent Foley-Bourgon
Advertisement
I wrote a small program to control Xmms remotely. The program uses Ruby and the web framework Wee. Here it is:
require "rubygems"
require "xmms"
class Main < Wee::Component
def initialize
super()
# Put your own initialization code below...
@xmms = Xmms::Remote.new
end
# --------------------------------------------
# Rendering
# --------------------------------------------
def render
song = @xmms.get_playlist_title
songs = @xmms.playlist.map { |s| s.first }
id = (songs.index(song)).to_s
ids = (0...songs.size).collect { |i| i.to_s }
r.h1("Xmms remote control")
r.text(song)
r.paragraph
r.form do
r.select_list(ids).multiple.labels(songs).selected(id.to_s).callback { |s|
@xmms.playlist_pos = s[0].to_i
}
r.submit_button.value("Goto")
r.paragraph
[:prev, :pause, :stop, :play, :next].each { |sym|
r.anchor.callback { @xmms.send(sym) }.with { r.text(sym.to_s.capitalize) }
r.space
}
end
end
end
That's the thing I like about Ruby, it's easy to build a little something for your own usage.
Read: Web-based Xmms control program