Class: Sonos::Device::Speaker
- Includes:
- Endpoint::AVTransport, Endpoint::Alarm, Endpoint::ContentDirectory, Endpoint::Device, Endpoint::Rendering, Endpoint::Upnp, Features::Voiceover
- Defined in:
- lib/sonos/device/speaker.rb
Overview
Used for PLAY:3, PLAY:5, PLAYBAR, SUB, CONNECT and CONNECT:AMP
Constant Summary collapse
- MODELS =
{ :'S1' => 'PLAY:1', # Released Oct 2013 :'S3' => 'PLAY:3', # Released Jul 2011 :'S5' => 'PLAY:5', # Released Nov 2009 :'S9' => 'PLAYBAR', # Released Feb 2013 :'Sub' => 'SUB', # Released May 2012 :'ZP80' => 'ZP80', # Released Apr 2006 :'ZP90' => 'CONNECT', # Released Aug 2008 :'ZP100' => 'ZP100', # Released Jan 2005 :'ZP120' => 'CONNECT:AMP' # Released Aug 2008 }.freeze
Constants included from Endpoint::Alarm
Endpoint::Alarm::ALARM_CLOCK_ENDPOINT, Endpoint::Alarm::ALARM_CLOCK_XMLNS
Constants included from Endpoint::Upnp
Endpoint::Upnp::ENDPOINT, Endpoint::Upnp::UPNP_TIMEOUT
Constants included from Endpoint::ContentDirectory
Endpoint::ContentDirectory::CONTENT_DIRECTORY_ENDPOINT, Endpoint::ContentDirectory::CONTENT_DIRECTORY_XMLNS
Constants included from Endpoint::Device
Endpoint::Device::DEVICE_ENDPOINT, Endpoint::Device::DEVICE_XMLNS
Constants included from Endpoint::Rendering
Endpoint::Rendering::RENDERING_ENDPOINT, Endpoint::Rendering::RENDERING_XMLNS
Constants included from Endpoint::AVTransport
Endpoint::AVTransport::TRANSPORT_ENDPOINT, Endpoint::AVTransport::TRANSPORT_XMLNS
Instance Attribute Summary
Attributes inherited from Base
#group, #group_master, #hardware_version, #icon, #ip, #mac_address, #model_number, #name, #serial_number, #services, #software_version, #uid, #zone_type
Class Method Summary collapse
Instance Method Summary collapse
- #crossfade_off ⇒ Object
- #crossfade_on ⇒ Object
- #get_playmode ⇒ Object
- #repeat_off ⇒ Object
- #repeat_on ⇒ Object
- #set_crossfade(crossfade) ⇒ Object
- #set_playmode(status = {:shuffle => false, :repeat => false}) ⇒ Object
- #shuffle_off ⇒ Object
- #shuffle_on ⇒ Object
- #shuffle_repeat_change(command) ⇒ Object
- #speaker? ⇒ Boolean
Methods included from Features::Voiceover
Methods included from Endpoint::Alarm
#create_alarm, #destroy_alarm, #disable_alarm, #enable_alarm, #is_alarm_enabled?, #list_alarms, #set_alarm_volume, #update_alarm
Methods included from Endpoint::Upnp
#subscribe_to_upnp_events, #unsubscribe_from_upnp_events
Methods included from Endpoint::ContentDirectory
Methods included from Endpoint::Device
#create_pair_with, #separate_pair, #status_light_enabled=, #status_light_enabled?
Methods included from Endpoint::Rendering
#bass, #bass=, #loudness, #loudness=, #mute, #muted?, #treble, #treble=, #unmute, #volume, #volume=
Methods included from Endpoint::AVTransport
#add_rdio_to_queue, #add_spotify_to_queue, #add_to_queue, #clear_queue, #get_player_state, #group, #has_music?, #is_playing?, #join, #line_in, #next, #now_playing, #pause, #play, #previous, #remove_from_queue, #save_queue, #seek, #select_track, #set_sleep_timer, #stop, #ungroup
Methods inherited from Base
#data, #data=, detect, #initialize, #model
Constructor Details
This class inherits a constructor from Sonos::Device::Base
Class Method Details
.models ⇒ Object
29 30 31 |
# File 'lib/sonos/device/speaker.rb', line 29 def self.models MODELS end |
Instance Method Details
#crossfade_off ⇒ Object
57 58 59 |
# File 'lib/sonos/device/speaker.rb', line 57 def crossfade_off set_crossfade(false) end |
#crossfade_on ⇒ Object
53 54 55 |
# File 'lib/sonos/device/speaker.rb', line 53 def crossfade_on set_crossfade(true) end |
#get_playmode ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/sonos/device/speaker.rb', line 88 def get_playmode doc = Nokogiri::XML(open("http://#{self.group_master.ip}:#{Sonos::PORT}/status/playmode")) playmode = {} playmode[:shuffle] = doc.xpath('//Shuffle').inner_text == "On" playmode[:repeat] = doc.xpath('//Repeat').inner_text == "On" playmode[:crossfade] = doc.xpath('//Crossfade').inner_text == "On" playmode end |
#repeat_off ⇒ Object
49 50 51 |
# File 'lib/sonos/device/speaker.rb', line 49 def repeat_off shuffle_repeat_change("repeat_off") end |
#repeat_on ⇒ Object
45 46 47 |
# File 'lib/sonos/device/speaker.rb', line 45 def repeat_on shuffle_repeat_change("repeat_on") end |
#set_crossfade(crossfade) ⇒ Object
83 84 85 86 |
# File 'lib/sonos/device/speaker.rb', line 83 def set_crossfade(crossfade) crossfade_value = crossfade ? 1 : 0 ('SetCrossfadeMode', "<InstanceID>0</InstanceID><CrossfadeMode>#{crossfade_value}</CrossfadeMode>") end |
#set_playmode(status = {:shuffle => false, :repeat => false}) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/sonos/device/speaker.rb', line 76 def set_playmode(status = {:shuffle => false, :repeat => false}) ('SetPlayMode', "<NewPlayMode>SHUFFLE</NewPlayMode>") if (status[:shuffle] && status[:repeat] ) ('SetPlayMode', "<NewPlayMode>SHUFFLE_NOREPEAT</NewPlayMode>") if (status[:shuffle] && !status[:repeat]) ('SetPlayMode', "<NewPlayMode>REPEAT_ALL</NewPlayMode>") if (!status[:shuffle] && status[:repeat] ) ('SetPlayMode', "<NewPlayMode>NORMAL</NewPlayMode>") if (!status[:shuffle] && !status[:repeat]) end |
#shuffle_off ⇒ Object
41 42 43 |
# File 'lib/sonos/device/speaker.rb', line 41 def shuffle_off shuffle_repeat_change("shuffle_off") end |
#shuffle_on ⇒ Object
37 38 39 |
# File 'lib/sonos/device/speaker.rb', line 37 def shuffle_on shuffle_repeat_change("shuffle_on") end |
#shuffle_repeat_change(command) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/sonos/device/speaker.rb', line 61 def shuffle_repeat_change(command) status = get_playmode case command when "shuffle_on" status[:shuffle] = true; when "shuffle_off" status[:shuffle] = false; when "repeat_on" status[:repeat] = true; when "repeat_off" status[:repeat] = false; end set_playmode(status) end |
#speaker? ⇒ Boolean
33 34 35 |
# File 'lib/sonos/device/speaker.rb', line 33 def speaker? services.include?('urn:upnp-org:serviceId:MusicServices') end |