Constants

STATE_STOPPED

STATE_STOPPED = 201

No music playing, but not paused.

This is a rare state, but can be encountered after an upgrade, or if the queue was cleared

STATE_PLAYING

STATE_PLAYING = 202

Currently plating music.

STATE_PAUSED

STATE_PAUSED = 203

Music is currently paused.

STATE_TRANSITIONING

STATE_TRANSITIONING = 204

The speaker is currently working on either playing or pausing.

Check it's state again in a second or two

STATE_UNKNOWN

STATE_UNKNOWN = 205

The speaker is in an unknown state.

This should only happen if Sonos introduce a new state that this code has not been updated to handle.

Methods

getIp()

getIp() : string

Get the IP address of this speaker.

Returns

string

getName()

getName() : string

Get the "Friendly" name of this speaker.

Returns

string

getRoom()

getRoom() : string

Get the room name of this speaker.

Returns

string

updateGroup()

updateGroup() : void

Remove any previously established group for this speaker.

setGroup()

setGroup(string  $group) : void

Set which group this speaker belongs to.

Parameters

string $group

The group id

getGroup()

getGroup() : string

Get the uuid of the group this speaker is a member of.

Returns

string

isCoordinator()

isCoordinator() : boolean

Check if this speaker is the coordinator of it's current group.

Returns

boolean

getUuid()

getUuid() : string

Get the uuid of this speaker.

Returns

string —

The uuid of this speaker

getVolume()

getVolume() : integer

Get the current volume of this speaker.

Returns

integer —

The current volume between 0 and 100

setVolume()

setVolume(integer  $volume) : $this

Adjust the volume of this speaker to a specific value.

Parameters

integer $volume

The amount to set the volume to between 0 and 100

Returns

$this

adjustVolume()

adjustVolume(integer  $adjust) : $this

Adjust the volume of this speaker by a relative amount.

Parameters

integer $adjust

The amount to adjust by between -100 and 100

Returns

$this

isMuted()

isMuted() : boolean

Check if this speaker is currently muted.

Returns

boolean

mute()

mute(boolean  $mute = true) : $this

Mute this speaker.

Parameters

boolean $mute

Whether the speaker should be muted or not

Returns

$this

unmute()

unmute() : $this

Unmute this speaker.

Returns

$this

setIndicator()

setIndicator(boolean  $on) : $this

Turn the indicator light on or off.

Parameters

boolean $on

Whether the indicator should be on or off

Returns

$this

getIndicator()

getIndicator() : boolean

Check whether the indicator light is on or not.

Returns

boolean

getTreble()

getTreble() : integer

Get the treble equalisation level.

Returns

integer

setTreble()

setTreble(integer  $treble) : $this

Set the treble equalisation.

Parameters

integer $treble

The treble level (between -10 and 10)

Returns

$this

getBass()

getBass() : integer

Get the bass equalisation level.

Returns

integer

setBass()

setBass(integer  $bass) : $this

Set the bass equalisation.

Parameters

integer $bass

The bass level (between -10 and 10)

Returns

$this

getLoudness()

getLoudness() : boolean

Check whether loudness normalisation is on or not.

Returns

boolean

setLoudness()

setLoudness(boolean  $on) : $this

Set whether loudness normalisation is on or not.

Parameters

boolean $on

Whether loudness should be on or not

Returns

$this

getStateName()

getStateName() : string

Get the current state of the group of speakers as the string reported by sonos: PLAYING, PAUSED_PLAYBACK, etc

Returns

string

getState()

getState() : integer

Get the current state of the group of speakers.

Returns

integer —

One of the class STATE_ constants

setState()

setState(integer  $state) : self

Set the state of the group.

Parameters

integer $state

One of the class STATE_ constants

Returns

self

play()

play() : self

Start playing the active music for this group.

Returns

self

pause()

pause() : self

Pause the group.

Returns

self

next()

next() : self

Skip to the next track in the current queue.

Returns

self

previous()

previous() : self

Skip back to the previous track in the current queue.

Returns

self

selectTrack()

selectTrack(integer  $position) : self

Skip to the specific track in the current queue.

Parameters

integer $position

The zero-based position of the track to skip to

Returns

self

seek()

seek(\duncan3dc\Sonos\Interfaces\Utils\TimeInterface  $position) : self

Seeks to a specific position within the current track.

Parameters

\duncan3dc\Sonos\Interfaces\Utils\TimeInterface $position

The position to seek to in the track

Returns

self

getMediaInfo()

getMediaInfo() : array

Get the currently active media info.

Returns

array

isStreaming()

isStreaming() : boolean

Check if this controller is currently playing a stream.

Returns

boolean

useStream()

useStream(\duncan3dc\Sonos\Tracks\Stream  $stream) : self

Play a stream on this controller.

Parameters

\duncan3dc\Sonos\Tracks\Stream $stream

The Stream object to play

Returns

self

useLineIn()

useLineIn(\duncan3dc\Sonos\Interfaces\SpeakerInterface|null  $speaker = null) : self

Play a line-in from a speaker.

If no speaker is passed then the current controller's is used.

Parameters

\duncan3dc\Sonos\Interfaces\SpeakerInterface|null $speaker

The speaker to get the line-in from

Returns

self

isUsingQueue()

isUsingQueue() : boolean

Check if this controller is currently using its queue.

Returns

boolean

useQueue()

useQueue() : self

Set this controller to use its queue (rather than a stream).

Returns

self

addSpeaker()

addSpeaker(\duncan3dc\Sonos\Interfaces\SpeakerInterface  $speaker) : self

Adds the specified speaker to the group of this Controller.

Parameters

\duncan3dc\Sonos\Interfaces\SpeakerInterface $speaker

The speaker to add to the group

Returns

self

removeSpeaker()

removeSpeaker(\duncan3dc\Sonos\Interfaces\SpeakerInterface  $speaker) : self

Removes the specified speaker from the group of this Controller.

Parameters

\duncan3dc\Sonos\Interfaces\SpeakerInterface $speaker

The speaker to remove from the group

Returns

self

getMode()

getMode() : array

Get the current play mode settings.

Returns

array —

An array with 2 boolean elements (shuffle and repeat)

setMode()

setMode(array  $options) : self

Set the current play mode settings.

Parameters

array $options

An array with 2 boolean elements (shuffle and repeat)

Returns

self

getRepeat()

getRepeat() : boolean

Check if repeat is currently active.

Returns

boolean

setRepeat()

setRepeat(boolean  $repeat) : self

Turn repeat mode on or off.

Parameters

boolean $repeat

Whether repeat should be on or not

Returns

self

getShuffle()

getShuffle() : boolean

Check if shuffle is currently active.

Returns

boolean

setShuffle()

setShuffle(boolean  $shuffle) : self

Turn shuffle mode on or off.

Parameters

boolean $shuffle

Whether shuffle should be on or not

Returns

self

getCrossfade()

getCrossfade() : boolean

Check if crossfade is currently active.

Returns

boolean

setCrossfade()

setCrossfade(boolean  $crossfade) : self

Turn crossfade on or off.

Parameters

boolean $crossfade

Whether crossfade should be on or not

Returns

self

exportState()

exportState(boolean  $pause = true) : \duncan3dc\Sonos\Interfaces\ControllerStateInterface

Grab the current state of the Controller (including it's queue and playing attributes).

Parameters

boolean $pause

Whether to pause the controller or not

Returns

\duncan3dc\Sonos\Interfaces\ControllerStateInterface

restoreState()

restoreState(\duncan3dc\Sonos\Interfaces\ControllerStateInterface  $state) : self

Restore the Controller to a previously exported state.

Parameters

\duncan3dc\Sonos\Interfaces\ControllerStateInterface $state

The state to be restored

Returns

self

interrupt()

interrupt(\duncan3dc\Sonos\Interfaces\UriInterface  $track, integer  $volume = null) : self

Interrupt the current audio with a track.

The current state of the controller is stored, the passed track is played, and then when it has finished the previous state of the controller is restored. This is useful for making announcements over the Sonos network.

Parameters

\duncan3dc\Sonos\Interfaces\UriInterface $track

The track to play

integer $volume

The volume to play the track at

Returns

self