Browse files

Added a song info pane

  • Loading branch information...
1 parent c769d1f commit 6709b4e46a8485d26b6fda93e3125d80316d27d8 @danopia committed May 17, 2010
Showing with 66 additions and 8 deletions.
  1. +47 −8 panes/songinfo.rb
  2. +19 −0 remora
View
55 panes/songinfo.rb
@@ -1,7 +1,9 @@
module Remora
class SongInfoPane < Luck::Alert
- def initialize display
- super display, 60, 15, 'Song Info'
+ attr_reader :song
+
+ def initialize display, song=nil
+ super display, 60, 16, 'Song Info'
hide!
@@ -12,13 +14,22 @@ def initialize display
self.alignment = :center
on_submit do
- display[:songinfo].hide!
- display.dirty!
+ display.client.queue << song
- #~ $results = client.user.favorites
- #~ display[:main, :results].data = $results
- #~ display[:main].title = "Your Favorites"
+ unless display.client.now_playing
+ Thread.new do
+ begin
+ display.client.queue.play_radio
+ rescue => ex
+ display.close
+ puts ex.class, ex.message, ex.backtrace
+ exit
+ end
+ end
+ end
+ display.panes.delete :songinfo
+ display.modal = nil
display.focus :main, :search
display.dirty!
end
@@ -30,10 +41,38 @@ def initialize display
end
on_submit do
- display[:songinfo].hide!
+ display.panes.delete :songinfo
+ display.modal = nil
display.focus :main, :search
display.dirty!
end
+
+ self.song = song if song
+ end
+
+ def song= song
+ @song = song
+
+ list = controls[:details].data = []
+
+ list << "Title: #{song.title}"
+ list << "Album: #{song.album}"
+ list << "Artist: #{song.artist}"
+
+ list << ''
+
+ minutes = song.duration.to_i / 60
+ seconds = song.duration.to_i - minutes*60
+ list << "Length: #{format '%d:%02d', minutes, seconds.to_i}"
+
+ list << "Track: #{song.data['TrackNum']}"
+ list << "Year: #{song.data['Year']}"
+
+ list << ''
+
+ list << "Song plays: #{song.data['SongPlays']}"
+ list << "Artist plays: #{song.data['ArtistPlays']}"
+ list << "Popularity: #{song.data['Popularity']}"
end
end
end
View
19 remora
@@ -77,6 +77,15 @@ begin
display.pane :queue, 1, 1, 20, -15, 'Queue' do
control :songs, Luck::ListBox, 1, 1, -1, -1 do
number!
+
+ on_submit do |list, song|
+ next unless song.is_a? GrooveShark::Song
+
+ pane = Remora::SongInfoPane.new(display, song)
+ display.pane :songinfo, pane
+ display.modal = pane
+ display[:songinfo, :close].focus!
+ end
end
end
@@ -160,6 +169,16 @@ begin
end
end
end
+ elsif query =~ /^\/info ([0-9]+)$/ && $results
+ index = $1.to_i - 1
+ next if index < 0 || index > $results.size
+
+ song = $results[index]
+
+ pane = Remora::SongInfoPane.new(display, song)
+ display.pane :songinfo, pane
+ display.modal = pane
+ display[:songinfo, :close].focus!
elsif query == '/pause'
client.player && client.player.pause
elsif query == '/stop'

0 comments on commit 6709b4e

Please sign in to comment.