Example #1
0
 /**
  * Update the track properties using an xml element.
  *
  * @param XmlElement $xml The xml element representing the track meta data
  * @param Controller $controller A controller instance to communicate with
  *
  * @return static
  */
 public static function createFromXml(XmlElement $xml, Controller $controller)
 {
     $track = new static($xml->getTag("res"));
     $track->title = (string) $xml->getTag("title");
     if ($stream = (string) $xml->getTag("streamContent")) {
         $bits = explode(" - ", $stream);
         $track->artist = array_shift($bits);
         $track->title = implode(" - ", $bits);
         $track->album = "";
     } else {
         $track->artist = (string) $xml->getTag("creator");
         $track->album = (string) $xml->getTag("album");
     }
     # Cast the node to a string first (we do this instead of calling nodeValue in case the object is null)
     $number = (string) $xml->getTag("originalTrackNumber");
     # Then convert to a number
     $track->number = (int) $number;
     if ($art = (string) $xml->getTag("albumArtURI")) {
         if (substr($art, 0, 4) !== "http") {
             $art = ltrim($art, "/");
             $art = sprintf("http://%s:1400/%s", $controller->ip, $art);
         }
         $track->albumArt = $art;
     }
     if ($xml->hasAttribute("id")) {
         $track->queueId = $xml->getAttribute("id");
     }
     return $track;
 }
Example #2
0
 /**
  * Create a stream from an xml element.
  *
  * @param XmlElement $xml The xml element representing the track meta data
  * @param Controller $controller A controller instance to communicate with
  *
  * @return static
  */
 public static function createFromXml(XmlElement $xml, Controller $controller)
 {
     return new static($xml->getTag("res"));
 }
Example #3
0
 /**
  * Create a stream from an xml element.
  *
  * @param XmlElement $xml The xml element representing the track meta data
  * @param Controller $controller A controller instance to communicate with
  *
  * @return static
  */
 public static function createFromXml(XmlElement $xml, Controller $controller)
 {
     return new static($xml->getTag("res")->nodeValue, $xml->getTag("title")->nodeValue);
 }
Example #4
0
 /**
  * Create a new Track instance from a URI.
  *
  * @param XmlElement $xml The xml element representing the track meta data.
  *
  * @return Track
  */
 public function createFromXml(XmlElement $xml)
 {
     $uri = (string) $xml->getTag("res");
     $class = $this->guessTrackClass($uri);
     return $class::createFromXml($xml, $this->controller);
 }
Example #5
0
 /**
  * Create an instance of the Alarm class.
  *
  * @param XmlElement $xml The xml element with the relevant attributes
  * @param Network $network A Network instance this alarm is from
  */
 public function __construct(XmlElement $xml, Network $network)
 {
     $this->id = $xml->getAttribute("ID");
     $this->attributes = $xml->getAttributes();
     $this->network = $network;
 }