Esempio n. 1
0
 private function save()
 {
     $file = $this->getFile();
     $data = array('current' => $this->currentPlaying, 'items' => $this->items);
     Logger::debug('Saving to ' . $file, self::$logfile);
     $res = file_put_contents($file, serialize($data));
     if (!$res) {
         Logger::error('Not able to write ' . $file, self::$logfile);
     }
 }
Esempio n. 2
0
 public function getChilds($device, array $data)
 {
     Logger::debug('Starting ' . __METHOD__ . ' with device "' . $device . '" and params ' . print_r($data, true), self::$logfile);
     try {
         $device = UPnP::getDevice($device);
         $client = $device->getClient('ContentDirectory');
         $data['BrowseFlag'] = 'BrowseDirectChildren';
         $data = $client->Browse($data);
         Logger::debug('Got data: ' . json_encode($data), self::$logfile);
         if (isset($data['Result'])) {
             $data['Result'] = $this->prepareMetaData($data['Result']);
         }
     } catch (UPnPException $e) {
         Logger::error('Got Exception: ' . $e->getMessage(), self::$logfile);
     }
     Logger::debug('Finished ' . __METHOD__, self::$logfile);
     $this->respond($data);
 }
Esempio n. 3
0
 public function search($device, array $data)
 {
     Logger::debug('Starting ' . __METHOD__ . ' with device "' . $device . '" and params ' . print_r($data, true), self::$logfile);
     try {
         $device = UPnP::getDevice($device);
         $client = $device->getClient('ContentDirectory');
         $data = $client->Search($data);
         Logger::debug('Got data: ' . json_encode($data), self::$logfile);
         if (isset($data['Result'])) {
             $data['Result'] = $this->prepareMetaData($data['Result']);
         }
     } catch (UPnPException $e) {
         Logger::error('Got Exception: ' . $e->getMessage(), self::$logfile);
     }
     Logger::debug('Finished ' . __METHOD__, self::$logfile);
     //do something with sceneparser here
     foreach ($data['Result'] as &$item) {
         if (!is_array($item)) {
             continue;
         }
         if (!isset($item['title']) && !is_string($item['title'])) {
             continue;
         }
         $parser = new SceneParser($item['title']);
         $item['title'] = $parser->getTitle();
     }
     $this->respond($data);
 }