Ejemplo n.º 1
0
function doFileBrowse($path, $prefix)
{
    global $connection, $prefs;
    debuglog("Browsing " . $path, "DIRBROWSER");
    $parts = true;
    $foundfile = false;
    $filedata = array();
    $dircount = 0;
    fputs($connection, 'lsinfo "' . format_for_mpd($path) . '"' . "\n");
    while (!feof($connection) && $parts) {
        $parts = getline($connection);
        if (is_array($parts)) {
            $s = trim($parts[1]);
            if (substr($s, 0, 1) != ".") {
                switch ($parts[0]) {
                    case "file":
                        if (!$foundfile) {
                            $foundfile = true;
                        } else {
                            if (!$prefs['ignore_unplayable'] || array_key_exists('Title', $filedata) && substr($filedata['Title'], 0, 12) != "[unplayable]") {
                                printFileItem(getFormatName($filedata), $filedata['file'], $filedata['Time']);
                            }
                            $filedata = array();
                        }
                        $filedata[$parts[0]] = $parts[1];
                        break;
                    case "playlist":
                        if ($path != "") {
                            // Ignore playlists located at the root. This is cleaner and makes more sense
                            printPlaylistItem(basename($parts[1]), $parts[1]);
                        }
                        break;
                    case "directory":
                        printDirectoryItem($parts[1], basename($parts[1]), $prefix, $dircount, false);
                        $dircount++;
                        break;
                    case "Title":
                    case "Time":
                    case "Artist":
                    case "Album":
                        $filedata[$parts[0]] = $parts[1];
                        break;
                }
            }
        }
    }
    if (array_key_exists('file', $filedata)) {
        if (!$prefs['ignore_unplayable'] || array_key_exists('Title', $filedata) && substr($filedata['Title'], 0, 12) != "[unplayable]") {
            printFileItem(getFormatName($filedata), $filedata['file'], $filedata['Time']);
        }
    }
}
Ejemplo n.º 2
0
 public function getHTML($prefix, &$dircount)
 {
     if ($this->name !== null) {
         if (count($this->children) > 0) {
             // Must be a directory
             printDirectoryItem($this->parent->getName($this->name), $this->name, $prefix, $dircount, true);
             $dircount++;
             foreach ($this->children as $child) {
                 $child->getHTML($prefix, $dircount);
             }
             print '</div>';
         } else {
             if (array_key_exists('playlist', $this->filedata)) {
                 printPlaylistItem($this->filedata['file_display_name'], $this->filedata['file']);
             } else {
                 printFileItem($this->filedata['file_display_name'], $this->filedata['file'], $this->filedata['Time']);
             }
         }
     } else {
         foreach ($this->children as $child) {
             $child->getHTML($prefix, $dircount);
         }
     }
 }