Playlist
extends Queue
in package
implements
PlaylistInterface
Provides an interface for managing Sonos playlists on the current network.
Table of Contents
Interfaces
- PlaylistInterface
- Provides an interface for managing Sonos playlists on the current network.
Properties
- $controller : ControllerInterface
- $id : string
- $trackFactory : FactoryInterface
- $updateId : int
- $name : string|null
Methods
- __construct() : mixed
- Create an instance of the Playlist class.
- addTrack() : $this
- Add a track to the playlist.
- addTracks() : $this
- Add tracks to the queue.
- clear() : $this
- Remove all tracks from the queue.
- count() : int
- Get the number of tracks in the queue.
- delete() : void
- Delete this playlist from the network.
- getId() : string
- Get the id of the playlist.
- getMetaData() : string
- Get the metadata xml for this object.
- getName() : string
- Get the name of the playlist.
- getTracks() : array<string|int, TrackInterface>
- Get tracks from the queue.
- getUri() : string
- Get the URI for this object.
- moveTrack() : $this
- Move a track from one position in the playlist to another.
- removeTrack() : bool
- Remove a track from the queue.
- removeTracks() : bool
- Remove tracks from the playlist.
- addUris() : void
- Add tracks to the playlist.
- browse() : array<string, string>
- Send a browse request to the controller to get queue info.
- getNextPosition() : int
- Calculate the position number to be used to add a track to the end of the playlist.
- getUpdateId() : int
- Get the next update id, or used the previously cached one.
- soap() : SoapResponse
- Send a soap request to the controller for this queue.
Properties
$controller
protected
ControllerInterface
$controller
The Controller instance this queue is for.
$id
protected
string
$id
The unique id of the queue.
$trackFactory
protected
FactoryInterface
$trackFactory
A factory to create tracks from.
$updateId
protected
int
$updateId
= 0
The current update id to be issued with upnp requests.
$name
private
string|null
$name
= null
The name of the playlist.
Methods
__construct()
Create an instance of the Playlist class.
public
__construct(ElementInterface|string $param, ControllerInterface $controller) : mixed
Parameters
- $param : ElementInterface|string
-
The id of the playlist, or an xml element with the relevant attributes
- $controller : ControllerInterface
-
A controller instance on the playlist's network
addTrack()
Add a track to the playlist.
public
addTrack(string|UriInterface $track[, int|null $position = null ]) : $this
Parameters
- $track : string|UriInterface
-
The URI of the track to add, or an object that implements the UriInterface
- $position : int|null = null
-
The position to insert the track in the playlist (zero-based), by default the track will be added to the end of the playlist
Return values
$thisaddTracks()
Add tracks to the queue.
public
addTracks(array<string|int, string>|array<string|int, UriInterface> $tracks[, int|null $position = null ]) : $this
Parameters
- $tracks : array<string|int, string>|array<string|int, UriInterface>
-
An array where each element is either the URI of the tracks to add, or an object that implements the UriInterface
- $position : int|null = null
-
The position to insert the tracks in the queue (zero-based), by default the tracks will be added to the end of the queue
Return values
$thisclear()
Remove all tracks from the queue.
public
clear() : $this
Return values
$thiscount()
Get the number of tracks in the queue.
public
count() : int
Return values
intdelete()
Delete this playlist from the network.
public
delete() : void
getId()
Get the id of the playlist.
public
getId() : string
Return values
stringgetMetaData()
Get the metadata xml for this object.
public
getMetaData() : string
Tags
Return values
stringgetName()
Get the name of the playlist.
public
getName() : string
Return values
stringgetTracks()
Get tracks from the queue.
public
getTracks([int $start = 0 ][, int $total = 0 ]) : array<string|int, TrackInterface>
Parameters
- $start : int = 0
-
The zero-based position in the queue to start from
- $total : int = 0
-
The maximum number of tracks to return
Return values
array<string|int, TrackInterface>getUri()
Get the URI for this object.
public
getUri() : string
Tags
Return values
stringmoveTrack()
Move a track from one position in the playlist to another.
public
moveTrack(int $from, int $to) : $this
Parameters
- $from : int
-
The current position of the track in the playlist (zero-based)
- $to : int
-
The desired position in the playlist (zero-based)
Return values
$thisremoveTrack()
Remove a track from the queue.
public
removeTrack(int $position) : bool
Parameters
- $position : int
-
The zero-based position of the track to remove
Return values
boolremoveTracks()
Remove tracks from the playlist.
public
removeTracks(array<string|int, int> $positions) : bool
Parameters
- $positions : array<string|int, int>
-
The zero-based positions of the tracks to remove
Return values
booladdUris()
Add tracks to the playlist.
protected
addUris(array<string|int, UriInterface> $tracks[, int $position = null ]) : void
If no $position is passed the track will be added to the end of the playlist
Parameters
- $tracks : array<string|int, UriInterface>
-
The tracks to add
- $position : int = null
-
The position to insert the track in the playlist (zero-based)
browse()
Send a browse request to the controller to get queue info.
protected
browse(string $type[, int $start = 0 ][, int $limit = 1 ]) : array<string, string>
Parameters
- $type : string
-
The type of browse request to send
- $start : int = 0
-
The position to start browsing from
- $limit : int = 1
-
The number of tracks from the queue to return
Return values
array<string, string>getNextPosition()
Calculate the position number to be used to add a track to the end of the playlist.
protected
getNextPosition() : int
Return values
intgetUpdateId()
Get the next update id, or used the previously cached one.
protected
getUpdateId() : int
Return values
intsoap()
Send a soap request to the controller for this queue.
protected
soap(string $service, string $action[, array<string, string|int|bool> $params = [] ]) : SoapResponse
Parameters
- $service : string
-
The service to send the request to
- $action : string
-
The action to call
- $params : array<string, string|int|bool> = []
-
The parameters to pass