Sonos A PHP library for interacting with Sonos speakers

Getting Started

Usage

Controllers

Services

Fun Stuff

Playing Mode

Details about what is playing is available via a State object, this can be retrieved and used like so:

$track = $controller->getStateDetails();

echo "Now Playing: " . $track->getTitle() . " from ";
echo $track->getAlbum() . " by " . $track->getArtist() . "\n";
echo "Running Time: " . $track->getPosition() . "/" . $track->getDuration() . "\n";

If you are not playing tracks but are streaming then the State object should be used a little differently:

$state = $controller->getStateDetails();

if ($state->isStreaming()) {
    echo "Currently Streaming: " . $state->getStream() . "\n";

    # Most streams do not provide extra information, so check before using
    if ($state->getArtist()) {
        echo "Artist: " . $state->getArtist() . "\n";
    }
}

For more information on the State object see the Tracks documentation.

Every day I’m shufflin’

In addition to what is currently playing, you can also control how it is playing:

if (!$controller->getShuffle()) {
    $controller->setShuffle(true);
}
if ($controller->getRepeat()) {
    $controller->setRepeat(false);
}
if ($controller->getCrossfade()) {
    $controller->setCrossfade(false);
}