duncan3dc\Sonos\Network::getPlaylists PHP Method

getPlaylists() public method

Get all the playlists available on the network.
public getPlaylists ( ) : duncan3dc\Sonos\Playlist[]
return duncan3dc\Sonos\Playlist[]
    public function getPlaylists()
    {
        if (is_array($this->playlists)) {
            return $this->playlists;
        }
        $controller = $this->getController();
        if ($controller === null) {
            throw new \RuntimeException("No controller found on the current network");
        }
        $data = $controller->soap("ContentDirectory", "Browse", ["ObjectID" => "SQ:", "BrowseFlag" => "BrowseDirectChildren", "Filter" => "", "StartingIndex" => 0, "RequestedCount" => 100, "SortCriteria" => ""]);
        $parser = new XmlParser($data["Result"]);
        $playlists = [];
        foreach ($parser->getTags("container") as $container) {
            $playlists[] = new Playlist($container, $controller);
        }
        return $this->playlists = $playlists;
    }