Module: Sonos::Endpoint::Rendering

Included in:
Device::Speaker
Defined in:
lib/sonos/endpoint/rendering.rb

Constant Summary collapse

RENDERING_ENDPOINT =
'/MediaRenderer/RenderingControl/Control'
RENDERING_XMLNS =
'urn:schemas-upnp-org:service:RenderingControl:1'

Instance Method Summary collapse

Instance Method Details

#bassFixnum

Get the current bass EQ.

Returns:

  • (Fixnum)

    the base EQ from -10 to 10



22
23
24
25
# File 'lib/sonos/endpoint/rendering.rb', line 22

def bass
  response = send_rendering_message('GetBass')
  response.body[:get_bass_response][:current_bass].to_i
end

#bass=(value) ⇒ Object

Set the bass EQ from -10 to 10.

Parameters:

  • the (Fixnum)

    desired bass EQ from -10 to 10



29
30
31
# File 'lib/sonos/endpoint/rendering.rb', line 29

def bass=(value)
  parse_response send_rendering_message('SetBass', value)
end

#loudnessBoolean

Get the loudness compenstation setting

Returns:

  • (Boolean)

    true if the speaker has loudness on and false if it is not



65
66
67
68
# File 'lib/sonos/endpoint/rendering.rb', line 65

def loudness
  response = send_rendering_message('GetLoudness')
  response.body[:get_loudness_response][:current_loudness] == '1'
end

#loudness=(value) ⇒ Object

Set the loudness compenstation setting

Parameters:

  • if (Boolean)

    the speaker has loudness on or not



72
73
74
# File 'lib/sonos/endpoint/rendering.rb', line 72

def loudness=(value)
  parse_response send_rendering_message('SetLoudness', value ? 1 : 0)
end

#muteObject

Mute the speaker



47
48
49
# File 'lib/sonos/endpoint/rendering.rb', line 47

def mute
  parse_response set_mute(true)
end

#muted?Boolean

Is the speaker muted?

Returns:

  • (Boolean)

    true if the speaker is muted and false if it is not



58
59
60
61
# File 'lib/sonos/endpoint/rendering.rb', line 58

def muted?
  response = send_rendering_message('GetMute')
  response.body[:get_mute_response][:current_mute] == '1'
end

#trebleFixnum

Get the current treble EQ.

Returns:

  • (Fixnum)

    the treble EQ from -10 to 10



35
36
37
38
# File 'lib/sonos/endpoint/rendering.rb', line 35

def treble
  response = send_rendering_message('GetTreble')
  response.body[:get_treble_response][:current_treble].to_i
end

#treble=(value) ⇒ Object

Set the treble EQ from -10 to 10.

Parameters:

  • the (Fixnum)

    desired treble EQ from -10 to 10



42
43
44
# File 'lib/sonos/endpoint/rendering.rb', line 42

def treble=(value)
  parse_response send_rendering_message('SetTreble', value)
end

#unmuteObject

Unmute the speaker



52
53
54
# File 'lib/sonos/endpoint/rendering.rb', line 52

def unmute
  parse_response set_mute(false)
end

#volumeFixnum

Get the current volume. Fixed volume speakers will always return 100.

Returns:

  • (Fixnum)

    the volume from 0 to 100



8
9
10
11
# File 'lib/sonos/endpoint/rendering.rb', line 8

def volume
  response = send_rendering_message('GetVolume')
  response.body[:get_volume_response][:current_volume].to_i
end

#volume=(value) ⇒ Object

Set the volume from 0 to 100. Trying to set the volume of a fixed volume speaker will fail.

Parameters:

  • the (Fixnum)

    desired volume from 0 to 100



16
17
18
# File 'lib/sonos/endpoint/rendering.rb', line 16

def volume=(value)
  parse_response send_rendering_message('SetVolume', value)
end