/** * Get the favourite radio shows/stations. * * @param int $type One of the class constants for either shows or stations * * @return Stream[] */ protected function getFavourites($type) { $items = []; $result = $this->controller->soap("ContentDirectory", "Browse", ["ObjectID" => "R:0/{$type}", "BrowseFlag" => "BrowseDirectChildren", "Filter" => "*", "StartingIndex" => 0, "RequestedCount" => 100, "SortCriteria" => ""]); $parser = new XmlParser($result["Result"]); $tagName = $type === self::STATIONS ? "item" : "container"; foreach ($parser->getTags($tagName) as $tag) { $name = $tag->getTag("title")->nodeValue; $uri = $tag->getTag("res")->nodeValue; $items[] = new Stream($uri, $name); } return $items; }
/** * Get tracks from the queue. * * @param int $start The zero-based position in the queue to start from * @param int $total The maximum number of tracks to return * * @return Track[] */ public function getTracks($start = 0, $total = 0) { $tracks = []; if ($total > 0 && $total < 100) { $limit = $total; } else { $limit = 100; } do { $data = $this->browse("DirectChildren", $start, $limit); $parser = new XmlParser($data["Result"]); foreach ($parser->getTags("item") as $item) { $tracks[] = $this->trackFactory->createFromXml($item); if ($total > 0 && count($tracks) >= $total) { return $tracks; } } $start += $limit; } while ($data["NumberReturned"] && $data["TotalMatches"] && count($tracks) < $data["TotalMatches"]); return $tracks; }
/** * Get all the alarms available on the network. * * @return Alarm[] */ public function getAlarms() { if (is_array($this->alarms)) { return $this->alarms; } $data = $this->getController()->soap("AlarmClock", "ListAlarms"); $parser = new XmlParser($data["CurrentAlarmList"]); $alarms = []; foreach ($parser->getTags("Alarm") as $tag) { $alarms[] = new Alarm($tag, $this); } return $this->alarms = $alarms; }