\duncan3dc\SonosPlaylist

Provides an interface for managing Sonos playlists on the current network.

Summary

Methods
Properties
Constants
__construct()
count()
getTracks()
addTrack()
addTracks()
removeTrack()
removeTracks()
clear()
getId()
getName()
moveTrack()
delete()
No public properties found
No constants found
soap()
browse()
getUpdateId()
getNextPosition()
addUris()
$id
$updateId
$controller
$trackFactory
N/A
No private methods found
$name
N/A

Properties

$id

$id : string

Type

string — The unique id of the queue.

$updateId

$updateId : integer

Type

integer — The current update id to be issued with upnp requests.

$name

$name : string|null

Type

string|null — The name of the playlist.

Methods

__construct()

__construct(string|\duncan3dc\DomParser\XmlElement  $param, \duncan3dc\Sonos\Interfaces\ControllerInterface  $controller) 

Create an instance of the Playlist class.

Parameters

string|\duncan3dc\DomParser\XmlElement $param

The id of the playlist, or an xml element with the relevant attributes

\duncan3dc\Sonos\Interfaces\ControllerInterface $controller

A controller instance on the playlist's network

count()

count() : integer

The the number of tracks in the queue.

Returns

integer

getTracks()

getTracks(integer  $start, integer  $total) : array<mixed,\duncan3dc\Sonos\Interfaces\TrackInterface>

Get tracks from the queue.

Parameters

integer $start

The zero-based position in the queue to start from

integer $total

The maximum number of tracks to return

Returns

array<mixed,\duncan3dc\Sonos\Interfaces\TrackInterface>

addTrack()

addTrack(string|\duncan3dc\Sonos\Interfaces\UriInterface  $track, integer  $position = null) : $this

Add a track to the queue.

Parameters

string|\duncan3dc\Sonos\Interfaces\UriInterface $track

The URI of the track to add, or an object that implements the UriInterface

integer $position

The position to insert the track in the queue (zero-based), by default the track will be added to the end of the queue

Returns

$this

addTracks()

addTracks(array<mixed,string>|array<mixed,\duncan3dc\Sonos\Interfaces\UriInterface>  $tracks, integer  $position = null) : $this

Add tracks to the queue.

Parameters

array<mixed,string>|array<mixed,\duncan3dc\Sonos\Interfaces\UriInterface> $tracks

An array where each element is either the URI of the tracks to add, or an object that implements the UriInterface

integer $position

The position to insert the tracks in the queue (zero-based), by default the tracks will be added to the end of the queue

Returns

$this

removeTrack()

removeTrack(integer  $position) : boolean

Remove a track from the queue.

Parameters

integer $position

The zero-based position of the track to remove

Returns

boolean

removeTracks()

removeTracks(array<mixed,integer>  $positions) : boolean

Remove tracks from the playlist.

Parameters

array<mixed,integer> $positions

The zero-based positions of the tracks to remove

Returns

boolean

clear()

clear() : $this

Remove all tracks from the queue.

Returns

$this

getId()

getId() : string

Get the id of the playlist.

Returns

string

getName()

getName() : string

Get the name of the playlist.

Returns

string

moveTrack()

moveTrack(integer  $from, integer  $to) : $this

Move a track from one position in the playlist to another.

Parameters

integer $from

The current position of the track in the playlist (zero-based)

integer $to

The desired position in the playlist (zero-based)

Returns

$this

delete()

delete() : void

Delete this playlist from the network.

soap()

soap(string  $service, string  $action, array  $params = array()) : mixed

Send a soap request to the controller for this queue.

Parameters

string $service

The service to send the request to

string $action

The action to call

array $params

The parameters to pass

Returns

mixed

browse()

browse(string  $type, integer  $start, integer  $limit = 1) : mixed

Send a browse request to the controller to get queue info.

Parameters

string $type

The type of browse request to send

integer $start

The position to start browsing from

integer $limit

The number of tracks from the queue to return

Returns

mixed

getUpdateId()

getUpdateId() : integer

Get the next update id, or used the previously cached one.

Returns

integer

getNextPosition()

getNextPosition() : integer

Calculate the position number to be used to add a track to the end of the playlist.

Returns

integer

addUris()

addUris(array<mixed,\duncan3dc\Sonos\Interfaces\UriInterface>  $tracks, integer  $position = null) : void

Add tracks to the playlist.

If no $position is passed the track will be added to the end of the playlist

Parameters

array<mixed,\duncan3dc\Sonos\Interfaces\UriInterface> $tracks

The tracks to add

integer $position

The position to insert the track in the playlist (zero-based)