class Site
Attributes
channels[R]
current_channel[R]
is_di_plus[R]
is_mplayer[R]
is_spotify[R]
name[R]
player[RW]
songs[RW]
Public Class Methods
new(options, name)
click to toggle source
# File lib/terminal_player/site.rb, line 9 def initialize(options, name) @name = name @songs = [] @channels = [] options[:cache] || options[:cache] = 512 options[:cache_min] || options[:cache_min] = 30 options[:url] || options[:url] = '' if options[:url].nil? || options[:url].empty? fail "no :url in the options hash sent to Site" end @is_di_plus = options[:di_plus] @is_spotify = !options[:url]['spotify:'].nil? if @is_spotify @current_channel = spotify_type(options[:url]) else @current_channel = options[:url].split('/').last @current_channel = @current_channel[0..@current_channel.index('.') - 1] end if @is_spotify @is_mplayer = false @player = SpotiphyPlayer.new(options) else @is_mplayer = true @player = Mplayer.new({cache: options[:cache], cache_min: options[:cache_min], url: options[:url]}) end PlayerMessageObserver.new(self, @player) end
Public Instance Methods
play()
click to toggle source
# File lib/terminal_player/site.rb, line 44 def play @player.play end
song_changed()
click to toggle source
# File lib/terminal_player/site.rb, line 48 def song_changed changed notify_observers(Time.now, @songs) end
Private Instance Methods
spotify_type(uri)
click to toggle source
# File lib/terminal_player/site.rb, line 55 def spotify_type(uri) return 'playlist' if uri[':playlist:'] return 'album' if uri[':album:'] return 'track' if uri[':track:'] return uri end