示例#1
0
    $musicPath = "/public/media/music";
    $songListing = array();
    foreach (getDirContents($musicPath) as $contents) {
        $urlStart = strlen($musicPath) + 1;
        $rawurl = rawurlencode($contents);
        if (isFile($rawurl)) {
            // Artist
            $path = substr($contents, $urlStart);
            $artist = substr($path, 0, strpos($path, "/"));
            // Album
            $path = substr($path, strpos($path, "/") + 1, strlen($path));
            $album = substr($path, 0, strpos($path, "/"));
            // Title
            $path = substr($path, strpos($path, "/") + 1, strlen($path));
            $title = substr($path, 0, strpos($path, ".mp3"));
            //echo "Artist: " . $artist . "<br>";
            //echo "Album: " . $album . "<br>";
            //echo "Title: " . $title . "<br>";
            // Url
            $url = str_replace("%2F", "/", $rawurl);
            //echo "<a href=\"..$url\">$url</a>" . "<br><br>";
            $song = array("trackNo" => $trackNo, "artist" => $artist, "album" => $album, "title" => $title, "url" => $url);
            $trackNo++;
            //add song to song listing
            array_push($songListing, $song);
        }
    }
    return $songListing;
}
getSongListing();
示例#2
0
function getSongsTable()
{
    $rawsongs = getSongListing();
    $updatedSongsTable = changeArtistToId($rawsongs);
    $updatedSongsTable = changeAlbumToId($updatedSongsTable, getAlbumsTable());
    return $updatedSongsTable;
}