示例#1
0
 /**
  * status
  * This returns bool/int values for features, loop, repeat and any other features
  * That this localplay method supports. required function
  * This works as in requesting the status.xml file from vlc.
  */
 public function status()
 {
     $arrayholder = $this->_vlc->fullstate();
     //get status.xml via parser xmltoarray
     /* Construct the Array */
     $currentstat = $arrayholder['root']['state']['value'];
     if ($currentstat == 'playing') {
         $state = 'play';
     }
     //change to something ampache understands
     if ($currentstat == 'stop') {
         $state = 'stop';
     }
     if ($currentstat == 'paused') {
         $state = 'pause';
     }
     $array['state'] = $state;
     $array['volume'] = intval(intval($arrayholder['root']['volume']['value']) / 2.6);
     $array['repeat'] = $arrayholder['root']['repeat']['value'];
     $array['random'] = $arrayholder['root']['random']['value'];
     $array['track'] = htmlspecialchars_decode($arrayholder['root']['information']['meta-information']['title']['value'], ENT_NOQUOTES);
     $url_data = $this->parse_url($array['track']);
     $song = new Song($url_data['oid']);
     if ($song->title || $song->get_artist_name() || $song->get_album_name()) {
         $array['track_title'] = $song->title;
         $array['track_artist'] = $song->get_artist_name();
         $array['track_album'] = $song->get_album_name();
     } else {
         $array['track_title'] = htmlspecialchars(substr($arrayholder['root']['information']['meta-information']['title']['value'], 0, 25));
         $array['track_artist'] = htmlspecialchars(substr($arrayholder['root']['information']['meta-information']['artist']['value'], 0, 20));
     }
     return $array;
 }
示例#2
0
 /**
  * get_status
  * This returns bool/int values for features, loop, repeat and any other
  * features that this localplay method supports.
  */
 public function status()
 {
     $track = $this->_mpd->status['song'];
     /* Construct the Array */
     $array['state'] = $this->_mpd->status['state'];
     $array['volume'] = $this->_mpd->status['volume'];
     $array['repeat'] = $this->_mpd->status['repeat'];
     $array['random'] = $this->_mpd->status['random'];
     $array['track'] = $track + 1;
     $playlist_item = $this->_mpd->playlist[$track];
     $url_data = $this->parse_url($playlist_item['file']);
     debug_event('mdp.controller.php', 'Status result. Current song (' . $track . ') info: ' . json_encode($playlist_item), '5');
     if (count($url_data) > 0 && !empty($url_data['oid'])) {
         $song = new Song($url_data['oid']);
         $array['track_title'] = $song->title;
         $array['track_artist'] = $song->get_artist_name();
         $array['track_album'] = $song->get_album_name();
     } else {
         if (!empty($playlist_item['Title'])) {
             $array['track_title'] = $playlist_item['Title'];
         } else {
             if (!empty($playlist_item['Name'])) {
                 $array['track_title'] = $playlist_item['Name'];
             } else {
                 $array['track_title'] = $playlist_item['file'];
             }
         }
     }
     return $array;
 }
示例#3
0
 /**
  * status
  * This returns bool/int values for features, loop, repeat and any other features
  * that this localplay method supports.
  * This works as in requesting the xbmc properties
  */
 public function status()
 {
     if (!$this->_xbmc) {
         return false;
     }
     $array = array();
     try {
         $appprop = $this->_xbmc->Application->GetProperties(array('properties' => array('volume')));
         $array['volume'] = intval($appprop['volume']);
         try {
             $currentplay = $this->_xbmc->Player->GetItem(array('playerid' => $this->_playerId, 'properties' => array('file')));
             // We assume it's playing. No pause detection support.
             $array['state'] = 'play';
             $playprop = $this->_xbmc->Player->GetProperties(array('playerid' => $this->_playerId, 'properties' => array('repeat', 'shuffled')));
             $array['repeat'] = $playprop['repeat'] != "off";
             $array['random'] = strtolower($playprop['shuffled']) == 1;
             $array['track'] = $currentplay['file'];
             $url_data = $this->parse_url($array['track']);
             $song = new Song($url_data['oid']);
             if ($song->title || $song->get_artist_name() || $song->get_album_name()) {
                 $array['track_title'] = $song->title;
                 $array['track_artist'] = $song->get_artist_name();
                 $array['track_album'] = $song->get_album_name();
             }
         } catch (XBMC_RPC_Exception $ex) {
             debug_event('xbmc', 'get current item failed, player probably stopped. ' . $ex->getMessage(), 1);
             $array['state'] = 'stop';
         }
     } catch (XBMC_RPC_Exception $ex) {
         debug_event('xbmc', 'status failed: ' . $ex->getMessage(), 1);
     }
     return $array;
 }
示例#4
0
 /**
  * status
  * This returns bool/int values for features, loop, repeat and any other features
  * that this localplay method supports.
  * This works as in requesting the upnp properties
  */
 public function status()
 {
     debug_event('upnp', 'status', 5);
     if (!$this->_upnp) {
         return false;
     }
     $item = $this->_upnp->GetCurrentItem();
     $status = array();
     $status['state'] = $this->_upnp->GetState();
     $status['volume'] = $this->_upnp->GetVolume();
     $status['repeat'] = false;
     $status['random'] = false;
     $status['track'] = $item['link'];
     $status['track_title'] = $item['name'];
     $url_data = Stream_URL::parse($item['link']);
     if ($url_data != null) {
         $song = new Song($url_data['id']);
         if ($song != null) {
             $status['track_artist'] = $song->get_artist_name();
             $status['track_album'] = $song->get_album_name();
         }
     }
     return $status;
 }
示例#5
0
 /**
  * status
  * This returns bool/int values for features, loop, repeat and any other features
  * That this localplay method supports. required function
  */
 public function status()
 {
     /* Construct the Array */
     $array['state'] = $this->_httpq->state();
     $array['volume'] = $this->_httpq->get_volume();
     $array['repeat'] = $this->_httpq->get_repeat();
     $array['random'] = $this->_httpq->get_random();
     $array['track'] = $this->_httpq->get_now_playing();
     $url_data = $this->parse_url($array['track']);
     if (isset($url_data['oid'])) {
         $song = new Song($data['oid']);
         $array['track_title'] = $song->title;
         $array['track_artist'] = $song->get_artist_name();
         $array['track_album'] = $song->get_album_name();
     } else {
         $array['track_title'] = basename($array['track']);
     }
     return $array;
 }
示例#6
0
 /**
  * songs
  *
  * This returns an xml document from an array of song ids.
  * (Spiffy isn't it!)
  */
 public static function songs($songs)
 {
     if (count($songs) > self::$limit or self::$offset > 0) {
         $songs = array_slice($songs, self::$offset, self::$limit);
     }
     Song::build_cache($songs);
     Stream::set_session($_REQUEST['auth']);
     $string = "";
     // Foreach the ids!
     foreach ($songs as $song_id) {
         $song = new Song($song_id);
         // If the song id is invalid/null
         if (!$song->id) {
             continue;
         }
         $tag_string = self::tags_string(Tag::get_top_tags('song', $song_id));
         $rating = new Rating($song_id, 'song');
         $art_url = Art::url($song->album, 'album', $_REQUEST['auth']);
         $string .= "<song id=\"" . $song->id . "\">\n" . "\t<title><![CDATA[" . $song->title . "]]></title>\n" . "\t<artist id=\"" . $song->artist . '"><![CDATA[' . $song->get_artist_name() . "]]></artist>\n" . "\t<album id=\"" . $song->album . '"><![CDATA[' . $song->get_album_name() . "]]></album>\n" . $tag_string . "\t<filename><![CDATA[" . $song->file . "]]></filename>\n" . "\t<track>" . $song->track . "</track>\n" . "\t<time>" . $song->time . "</time>\n" . "\t<year>" . $song->year . "</year>\n" . "\t<bitrate>" . $song->bitrate . "</bitrate>\n" . "\t<mode>" . $song->mode . "</mode>\n" . "\t<mime>" . $song->mime . "</mime>\n" . "\t<url><![CDATA[" . Song::play_url($song->id) . "]]></url>\n" . "\t<size>" . $song->size . "</size>\n" . "\t<mbid>" . $song->mbid . "</mbid>\n" . "\t<album_mbid>" . $song->album_mbid . "</album_mbid>\n" . "\t<artist_mbid>" . $song->artist_mbid . "</artist_mbid>\n" . "\t<art><![CDATA[" . $art_url . "]]></art>\n" . "\t<preciserating>" . $rating->get_user_rating() . "</preciserating>\n" . "\t<rating>" . $rating->get_user_rating() . "</rating>\n" . "\t<averagerating>" . $rating->get_average_rating() . "</averagerating>\n" . "</song>\n";
     }
     // end foreach
     return self::_header() . $string . self::_footer();
 }