Class: XBMC
- Inherits:
-
Object
- Object
- XBMC
- Defined in:
- lib/xbmc.rb
Instance Method Summary collapse
- #clear_playlist ⇒ Object
-
#currently_playing ⇒ Object
returns a hash with details on the currently_playing track xbox.currently_playing #=> “La Vida Loca”.
-
#initialize(host, port = 80, playlist = 0) ⇒ XBMC
constructor
Creates a new instance using the hostname or IP address, port, and.
-
#pause ⇒ Object
(also: #unpause)
Pause or unpause the player.
-
#paused? ⇒ Boolean
Whether or not xbmc is paused.
-
#play_next ⇒ Object
Play the next track.
-
#playing? ⇒ Boolean
Whether or not a track is in progress.
-
#playlist ⇒ Object
An array of the currently loaded tracks.
-
#queue(song) ⇒ Object
Add a file to the queue.
-
#set_playlist(type = @playlist) ⇒ Object
0 = Music 1 = Video.
Constructor Details
#initialize(host, port = 80, playlist = 0) ⇒ XBMC
Creates a new instance using the hostname or IP address, port, and
13 14 15 16 17 18 19 20 |
# File 'lib/xbmc.rb', line 13 def initialize(host,port = 80, playlist = 0) @host = host @port = port @paused = false @playlist = playlist set_playlist end |
Instance Method Details
#clear_playlist ⇒ Object
66 67 68 |
# File 'lib/xbmc.rb', line 66 def clear_playlist send_command('ClearPlaylist',0) end |
#currently_playing ⇒ Object
returns a hash with details on the currently_playing track xbox.currently_playing #=> “La Vida Loca”
24 25 26 27 28 29 30 31 |
# File 'lib/xbmc.rb', line 24 def returning(Hash.new) do |result| send_command('getCurrentlyPlaying').search("//li").each do |item| key,*value = item.inner_html.split(':') result[key.downcase.to_sym] = value.join(':').chomp end end end |
#pause ⇒ Object Also known as: unpause
Pause or unpause the player. This is a simple toggle, it doesn’t check current state.
60 61 62 63 |
# File 'lib/xbmc.rb', line 60 def pause send_command('Pause') @paused = !@paused end |
#paused? ⇒ Boolean
Whether or not xbmc is paused
39 40 41 |
# File 'lib/xbmc.rb', line 39 def paused? @paused end |
#play_next ⇒ Object
Play the next track
54 55 56 |
# File 'lib/xbmc.rb', line 54 def play_next send_command('PlayNext') end |
#playing? ⇒ Boolean
Whether or not a track is in progress
34 35 36 |
# File 'lib/xbmc.rb', line 34 def [:filename] == "[Nothing Playing]" ? false : (true && !paused?) end |
#playlist ⇒ Object
An array of the currently loaded tracks
44 45 46 |
# File 'lib/xbmc.rb', line 44 def playlist send_command('getPlaylistContents',0).search("//li").map{|i| i.inner_html.chomp}.reject{|i| i == "[Empty]"} end |
#queue(song) ⇒ Object
Add a file to the queue. Specify the path to the file as xbmc would access it.
49 50 51 |
# File 'lib/xbmc.rb', line 49 def queue(song) send_command('addToPlaylist',song,0) end |
#set_playlist(type = @playlist) ⇒ Object
0 = Music 1 = Video
72 73 74 |
# File 'lib/xbmc.rb', line 72 def set_playlist(type=@playlist) send_command('SetCurrentPlaylist',type) end |