The Ultimate Home Jukebox by Charlie Munro and Mark Nelson Figure 3: Contents of "Radiohead - The Bends.m3u" \\mark\d\My Music\Radiohead\The Bends\1_Planet Telex.mp3 \\mark\d\My Music\Radiohead\The Bends\2_The Bends.mp3 \\mark\d\My Music\Radiohead\The Bends\3_High And Dry.mp3 \\mark\d\My Music\Radiohead\The Bends\4_Fake Plastic Trees.mp3 \\mark\d\My Music\Radiohead\The Bends\5_Bones.mp3 \\mark\d\My Music\Radiohead\The Bends\6_(Nice Dream).mp3 \\mark\d\My Music\Radiohead\The Bends\7_Just.mp3 \\mark\d\My Music\Radiohead\The Bends\8_My Iron Lung.mp3 \\mark\d\My Music\Radiohead\The Bends\9_Bullet Proof..I Wish I Was.mp3 \\mark\d\My Music\Radiohead\The Bends\10_Black Star.mp3 \\mark\d\My Music\Radiohead\The Bends\11_Sulk.mp3 \\mark\d\My Music\Radiohead\The Bends\12_Street Spirit (Fade Out).mp3 Example 1: idx = fileName.indexOf(" - "); // find the delimiter separating artist title = fileName.substring(idx + 3, fileName.length - 4); title = jTrim(title); href = rootPath + pathSeparator + Server.URLPathEncode(fileName); Response.Write("
" + title + "
\n"); Listing One <%@ LANGUAGE=JavaScript %> <% // Script to generate an alphabetical listing of files with links to // each file done in JavaScript to take advantage of the built-in // sorting capability for JavaScript arrays var m3uRoot = "/Playlists"; // Virtual directory for M3U files var lastArtist = " "; // used to check for unique artist names var thisLetter = ""; // current letter for index and listing var artist; // current artist's name from file name var title; // current album title from file name var href; // complete path to M3U file // get a listing of playlist files in the specified folder var fileList = GetFileList(m3uRoot); // sort the file list (in ASCII order, so A-Z is before a-z!) fileList = fileList.sort(); // get the number of playlist files to show a count in the page title var fileCount = fileList.length; // get the first letter of the first file - we'll need this to know // when we're at the top of the listing var firstLetter = fileList[0].charAt(0); // find out which browser is being used to view the page so that we // can write the URLs correctly var browser = Request.ServerVariables("HTTP_USER_AGENT").Item var isIE = (browser.indexOf("MSIE") != -1) // - - - start of the HTML document - - - %> The M3U Project

The M3U Project

<%= fileCount %> Titles for Your Enjoyment
(listed by artist and albums)

<% Response.Write("

"); // loop through files to get a list of first characters, and generate // links to headings for (var i = 0; i < fileList.length; i++) { fileName = fileList[i]; if (fileName.charAt(0) != thisLetter) { thisLetter = fileName.charAt(0); Response.Write("" + thisLetter + "\n"); } } Response.Write("

\n") for (i = 0; i < fileList.length; i++) { fileName = fileList[i]; // find the delimiter separating artist and album title idx = fileName.indexOf(" - "); if (idx != -1) { // get the artist name with leading and trailing spaces removed artist = jTrim(fileName.substring(0, idx)); if (artist != lastArtist) { // for each new artist, check to see if a new first character // is present, and start a new section if needed. if (artist.charAt(0) != lastArtist.charAt(0)) doNextLetter(artist.charAt(0)); Response.Write("
" + artist + "
\n"); lastArtist = artist; } title = fileName.substring(idx + 3, fileName.length - 4); title = jTrim(title); href = m3uRoot + "/" + fileName; if (!isIE) jReplace(fileName, " ", "%20", 1, -1, 1); Response.Write("
" + title + "
\n"); } } %> back to top 4