PHP Class duncan3dc\Sonos\Network

Inheritance: implements Psr\Log\LoggerAwareInterface
Mostrar archivo Open project: duncan3dc/sonos Class Usage Examples

Protected Properties

Property Type Description
$alarms duncan3dc\Sonos\Alarm[] | null Alarms that are available on the current network.
$cache Doctrine\Common\Cache\Cache The cache object to use for the expensive multicast discover to find Sonos devices on the network.
$logger Psr\Log\LoggerInterface The logging object.
$multicastAddress string The multicast address to use for SSDP discovery.
$networkInterface string The network interface to use for SSDP discovery.
$playlists Playlists[] | null Playlists that are available on the current network.
$speakers duncan3dc\Sonos\Speaker[] | null Speakers that are available on the current network.

Public Methods

Method Description
__construct ( Doctrine\Common\Cache\Cache $cache = null, Psr\Log\LoggerInterface $logger = null ) Create a new instance.
clearTopology ( ) : static Reset any previously gathered speaker information.
createPlaylist ( $name ) : duncan3dc\Sonos\Playlist Create a new playlist.
getAlarmById ( $id ) : duncan3dc\Sonos\Alarm | null Get alarms for the specified id.
getAlarms ( ) : duncan3dc\Sonos\Alarm[] Get all the alarms available on the network.
getController ( ) : Controller | null Get a Controller instance from the network.
getControllerByIp ( string $ip ) : Controller | null Get the coordinator for the specified ip address.
getControllerByRoom ( string $room ) : Controller | null Get the coordinator for the specified room name.
getControllers ( ) : Controller[] Get all the coordinators on the network.
getLogger ( ) : Psr\Log\LoggerInterface Get the logger object to use.
getNetworkInterface ( ) : string | integer | null Get the network interface currently in use
getPlaylistById ( $id ) : duncan3dc\Sonos\Playlist Get the playlist with the specified id.
getPlaylistByName ( $name ) : duncan3dc\Sonos\Playlist | null Get the playlist with the specified name.
getPlaylists ( ) : duncan3dc\Sonos\Playlist[] Get all the playlists available on the network.
getRadio ( ) : duncan3dc\Sonos\Services\Radio Get a Radio instance for the network.
getRadioShows ( ) : Stream[] Get the favourite radio shows.
getRadioStations ( ) : Stream[] Get the favourite radio stations.
getSpeakerByRoom ( string $room ) : duncan3dc\Sonos\Speaker | null Get a speaker with the specified room name.
getSpeakers ( ) : duncan3dc\Sonos\Speaker[] Get all the speakers on the network.
getSpeakersByRoom ( string $room ) : duncan3dc\Sonos\Speaker[] Get all the speakers with the specified room name.
hasPlaylist ( $name ) : boolean Check if a playlist with the specified name exists on this network.
setLogger ( Psr\Log\LoggerInterface $logger ) : static Set the logger object to use.
setMulticastAddress ( $multicastAddress ) : static Set the multicast address to use for SSDP discovery.
setNetworkInterface ( $networkInterface ) : static Set the network interface to use for SSDP discovery.

Protected Methods

Method Description
getCacheKey ( )
getDevices ( ) : string[] Get all the devices on the current network.

Method Details

__construct() public method

Create a new instance.
public __construct ( Doctrine\Common\Cache\Cache $cache = null, Psr\Log\LoggerInterface $logger = null )
$cache Doctrine\Common\Cache\Cache The cache object to use for the expensive multicast discover to find Sonos devices on the network
$logger Psr\Log\LoggerInterface The logging object

clearTopology() public method

Reset any previously gathered speaker information.
public clearTopology ( ) : static
return static

createPlaylist() public method

Create a new playlist.
public createPlaylist ( $name ) : duncan3dc\Sonos\Playlist
return duncan3dc\Sonos\Playlist

getAlarmById() public method

Get alarms for the specified id.
public getAlarmById ( $id ) : duncan3dc\Sonos\Alarm | null
return duncan3dc\Sonos\Alarm | null

getAlarms() public method

Get all the alarms available on the network.
public getAlarms ( ) : duncan3dc\Sonos\Alarm[]
return duncan3dc\Sonos\Alarm[]

getCacheKey() protected method

protected getCacheKey ( )

getController() public method

Useful for managing playlists/alarms, as these need a controller but it doesn't matter which one.
public getController ( ) : Controller | null
return Controller | null

getControllerByIp() public method

Get the coordinator for the specified ip address.
public getControllerByIp ( string $ip ) : Controller | null
$ip string The ip address of the speaker
return Controller | null

getControllerByRoom() public method

Get the coordinator for the specified room name.
public getControllerByRoom ( string $room ) : Controller | null
$room string The name of the room to look for
return Controller | null

getControllers() public method

Get all the coordinators on the network.
public getControllers ( ) : Controller[]
return Controller[]

getDevices() protected method

Get all the devices on the current network.
protected getDevices ( ) : string[]
return string[] An array of ip addresses

getLogger() public method

Get the logger object to use.
public getLogger ( ) : Psr\Log\LoggerInterface
return Psr\Log\LoggerInterface $logger The logging object

getNetworkInterface() public method

Get the network interface currently in use
public getNetworkInterface ( ) : string | integer | null
return string | integer | null The network interface name

getPlaylistById() public method

Get the playlist with the specified id.
public getPlaylistById ( $id ) : duncan3dc\Sonos\Playlist
return duncan3dc\Sonos\Playlist

getPlaylistByName() public method

If no case-sensitive match is found it will return a case-insensitive match.
public getPlaylistByName ( $name ) : duncan3dc\Sonos\Playlist | null
return duncan3dc\Sonos\Playlist | null

getPlaylists() public method

Get all the playlists available on the network.
public getPlaylists ( ) : duncan3dc\Sonos\Playlist[]
return duncan3dc\Sonos\Playlist[]

getRadio() public method

Get a Radio instance for the network.
public getRadio ( ) : duncan3dc\Sonos\Services\Radio
return duncan3dc\Sonos\Services\Radio

getRadioShows() public method

Get the favourite radio shows.
public getRadioShows ( ) : Stream[]
return duncan3dc\Sonos\Tracks\Stream[]

getRadioStations() public method

Get the favourite radio stations.
public getRadioStations ( ) : Stream[]
return duncan3dc\Sonos\Tracks\Stream[]

getSpeakerByRoom() public method

Get a speaker with the specified room name.
public getSpeakerByRoom ( string $room ) : duncan3dc\Sonos\Speaker | null
$room string The name of the room to look for
return duncan3dc\Sonos\Speaker | null

getSpeakers() public method

Get all the speakers on the network.
public getSpeakers ( ) : duncan3dc\Sonos\Speaker[]
return duncan3dc\Sonos\Speaker[]

getSpeakersByRoom() public method

Get all the speakers with the specified room name.
public getSpeakersByRoom ( string $room ) : duncan3dc\Sonos\Speaker[]
$room string The name of the room to look for
return duncan3dc\Sonos\Speaker[]

hasPlaylist() public method

If no case-sensitive match is found it will return a case-insensitive match.
public hasPlaylist ( $name ) : boolean
return boolean

setLogger() public method

Set the logger object to use.
public setLogger ( Psr\Log\LoggerInterface $logger ) : static
$logger Psr\Log\LoggerInterface
return static

setMulticastAddress() public method

Set the multicast address to use for SSDP discovery.
public setMulticastAddress ( $multicastAddress ) : static
return static

setNetworkInterface() public method

See the documentation on IP_MULTICAST_IF at http://php.net/manual/en/function.socket-get-option.php
public setNetworkInterface ( $networkInterface ) : static
return static

Property Details

$alarms protected_oe property

Alarms that are available on the current network.
protected Alarm[],duncan3dc\Sonos|null $alarms
return duncan3dc\Sonos\Alarm[] | null

$cache protected_oe property

The cache object to use for the expensive multicast discover to find Sonos devices on the network.
protected Cache,Doctrine\Common\Cache $cache
return Doctrine\Common\Cache\Cache

$logger protected_oe property

The logging object.
protected LoggerInterface,Psr\Log $logger
return Psr\Log\LoggerInterface

$multicastAddress protected_oe property

The multicast address to use for SSDP discovery.
protected string $multicastAddress
return string

$networkInterface protected_oe property

The network interface to use for SSDP discovery.
protected string $networkInterface
return string

$playlists protected_oe property

Playlists that are available on the current network.
protected Playlists[]|null $playlists
return Playlists[] | null

$speakers protected_oe property

Speakers that are available on the current network.
protected Speaker[],duncan3dc\Sonos|null $speakers
return duncan3dc\Sonos\Speaker[] | null