Beispiel #1
0
 public function getCurrentPlaylist()
 {
     $files = $this->mpd('playlist');
     if ($files === FALSE) {
         return array();
     }
     #print_r($files); die();
     // calculate the portion which should be rendered
     $status = $this->mpd('status');
     $listPos = isset($status['song']) ? $status['song'] : 0;
     $listLength = isset($status['playlistlength']) ? $status['playlistlength'] : 0;
     $minIndex = 0;
     $maxIndex = \Slim\Slim::getInstance()->config['mpd-playlist']['max-items'];
     if ($listLength > $maxIndex) {
         if ($listLength - $maxIndex < $listPos) {
             $minIndex = $listLength - $maxIndex;
             $maxIndex = $listLength - 1;
         } else {
             $minIndex = $listPos;
             $maxIndex = $listPos + $maxIndex - 1;
         }
     }
     if (1 == 2) {
         echo "<pre>";
         echo "min: " . $minIndex . "\n";
         echo "max: " . $maxIndex . "\n";
         echo "pos: " . $listPos . "\n";
         echo "len: " . $listLength . "\n";
         die;
     }
     $playlist = array();
     foreach ($files as $idx => $filepath) {
         if ($idx < $minIndex || $idx > $maxIndex) {
             continue;
         }
         $playlist[$idx] = \Slimpd\Track::getInstanceByPath($filepath);
     }
     return $playlist;
 }