Version 3.0
Version 3.0 contains a few breaking changes to make the library more robust, general usage should be unaffected, but if you’re providing any custom implementations of features then the following guide should help to get them compatible.
- The
SonosExceptionclass has been replaced by anExceptioninterface, so any try/catch blocks you have need to be updated. - By dropping support for older versions of PHP the library now contains more types where possible (eg union types).
- All the
soap()methods now return aSoapResponseinstance. - The state constants (eg STATE_PLAYING, etc) have moved from the
ControllerInterfaceto a newPlayStateenum.
Device Collections
If you provide a specific or custom collection to the Network instance then the following changes my affect you:
- The
Discoverycollection will only run the actual discovery if no devices have been added, so if you’re manually adding devices (withaddDevice()oraddIp()) then you’ll need to callgetDevices()first to ensure discovery still happens. - The
DeviceInterfaceno longer has agetXml()method, this has been replaced withgetName(),getRoom(), andgetUuid(). - The
isSpeaker()method has also been removed, this is now handled by aSpeakerscollection:$discovery = new \duncan3dc\Sonos\Devices\Discovery(); $collection = new \duncan3dc\Sonos\Devices\Speakers($discovery); $sonos = new \duncan3dc\Sonos\Network($collection);This is so that when Sonos releases new devices, you don’t need to wait for a new version of this library to be released, you can bypass this check like so:
$discovery = new \duncan3dc\Sonos\Devices\Discovery(); $sonos = new \duncan3dc\Sonos\Network($discovery);But please still submit the PR/Issue so that others can benefit!
Custom Tracks
- If you’re implementing a custom track (using the
TrackInterfaceand/orFactoryInterface) then the change from domparser v1 to v2 will impact you. - You’ll also need to implement the
createFromXml()static method on any custom track classes.