Click here to Skip to main content
15,894,896 members
Articles / Desktop Programming / MFC
Article

MP3 Playlist Generator

Rate me:
Please Sign up or sign in to vote.
4.29/5 (12 votes)
2 Jul 2003CPOL4 min read 259.1K   3.3K   32   21
This is a free tool for enumerating a specifically-structured MP3 collection and creating .m3u playlist files.

Sample Image - playlistgenerator.gif

Generated HTML file without stylesheet applied

Introduction

I wrote this tool because I grew tired of manually creating playlists each and every time I added an album to my collection. The tool recurses the directories of a specifically-structured MP3 collection on your hard disk. During the enumeration, several MP3 playlist files are created, allowing you to access your collection via a Web page.

This tool is for you if:

  • Your collection contains entire CDs and is arranged by artist and album (see "Directory Structure" below).
  • Your collection resides on a machine capable of being a Web server.

If you don't meet the above requirements, then please stop reading here.

Terminology

Host NameYour Web server's host name (e.g., server in the URL http://server/).
Virtual DirectoryThe path in the URL that points to your MP3 collection (e.g., mp3 in the URL http://server/mp3/).
MP3 Root DirectoryThe physical path on disk to your MP3 collection (e.g., E:\mp3).

Directory Structure

The playlist generator will work for you if your collection has the following directory structure:

  • <MP3 Root>
    • <Artist0>
      • <Album0>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
      • <Album1>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
    • <Artist1>
      • <Album0>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
      • <Album1>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
      ...
    • <ArtistN>
      • <Album0>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3
      • Album1>
        • <Song0>.mp3
        • <Sing1>.mp3
          ...
        • <SongN>.mp3

The artist, album, and song names do not have to be in any particular format; however, I find that prepending the track number to the song name helps if you like to listen to the tracks in the same order that they appear on the CD. A typical directory might look like the following:

  • mp3
    • Weird Al Yankovic
      • Permanent Record - Al In The Box - Disc 1
        • 01 My Bologna.mp3
        • 02 Another One Rides The Bus.mp3
          ...
        • 12 King Of Suede.mp3

The physical path on disk to such a directory would look like this: <drive letter>:\mp3\Weird Al Yankovic\Permanent Record - Al In The Box - Disc 1\.

Files Created During Execution (.htm and .m3u)

The following files are created during the execution of the MP3 Playlist Generator:

index.htmLocated in the MP3 Root Directory, this file contains links to all of the generated .m3u files, sorted alphabetically by artist and album. This is the file that you access via the Web server.
(e.g., <MP3 Root Directory>\index.htm)
All.m3uLocated in the MP3 Root Directory, this playlist contains entries for all songs by all artists in your collection
(e.g., <MP3 Root Directory>\All.m3u)
<Artist>.m3uLocated in the artist's directory, these playlists contain entries for all songs in all albums for the specified artist
(e.g., <MP3 Root Directory>\Weird Al Yankovic\Weird Al Yankovic.m3u)
<Album>.m3uLocated in each album's directory, these playlists contain entries for all songs in a particular album.
(e.g., <MP3 Root Directory>\Weird Al Yankovic\Permanent Record - Al In The Box - Disc 1\Permanent Record - Al In The Box - Disc 1.m3u)

If the files already exist, their contents are truncated, so each time the program is run, the playlists and the HTML files are all refreshed.

Setting Up Your MP3 Server

Enable IIS

In order to access the Web page created by the MP3 Playlist Generator, you will need to enable IIS. Please refer to your OS's documentation on how to install and enable IIS.

Create a Virtual Directory for your MP3 Root Directory

In the IIS MMC snap-in, create a virtual directory for your MP3 Root Directory. Please refer to your OS's documentation on how to create a virtual directory.

Enable Default Document Support for index.htm files

If not already enabled for your Web server, enable default document support for index.htm files. Please refer to your OS's documentation on how to enable default document support for specific file types.

Running the MP3 Playlist Generator

  • Copy the program to anywhere on your hard drive and launch it.
  • Insert appropriate values for Host Name, Virtual Directory, and MP3 Root Directory.
  • Click the "Generate .m3u Files" button.

That's it! You should now be able to browse to http://<Host Name>/<Virtual Directory>/ and view a list of your MP3 collection!

To-do List

This tool is by no means polished. Here is a short list of enhancements that I need to make:

  • Add stylesheet for generated HTML file (it's on my home computer, which doesn't have an Internet connection at the moment)
  • Persist user's settings in the registry. Currently, they are hard-coded into the app.
  • Insert a browse dialog to allow users to browse for their MP3 Root Directory.
  • Add a "last generated" timestamp to the HTML file.
  • Add statistics to the HTML file (# artists, # albums, # songs).

If you have any features you would like to see, please post them in the forum below.

History

VersionComments
1.0.0
03 Jul 2003
Initial public release.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Sagara Software, Inc.
United States United States
Jon is a senior software developer who loves using .NET to solve problems.

When he's not fooling around with computers or reading, he's busy spending time with his super wife, Kelly, and his three boys. He also likes to take his mountain bike for a spin.

Visit my blog

Comments and Discussions

 
GeneralXSPF and PLS playlist Pin
legenie28-Apr-09 2:43
legenie28-Apr-09 2:43 
GeneralAll m3u files generated.. all right.. but.... [modified] Pin
Katataniel17-Jul-07 5:25
Katataniel17-Jul-07 5:25 
GeneralRe: All m3u files generated.. all right.. but.... Pin
Katataniel17-Jul-07 9:01
Katataniel17-Jul-07 9:01 
GeneralRoot Directory Problem Pin
8-Dec-04 9:24
suss8-Dec-04 9:24 
GeneralWMA support... Pin
rcaddyuk10-Oct-04 2:37
rcaddyuk10-Oct-04 2:37 
GeneralRe: WMA support... Pin
Jon Sagara10-Oct-04 2:39
Jon Sagara10-Oct-04 2:39 
GeneralAnother Novice Question - PHP/MySQL app doing same Pin
Wireless Tech Radio10-Sep-04 6:33
Wireless Tech Radio10-Sep-04 6:33 
GeneralRe: Another Novice Question - PHP/MySQL app doing same Pin
Jon Sagara10-Sep-04 6:49
Jon Sagara10-Sep-04 6:49 
GeneralQ from a novice Pin
jkwipr19-May-04 9:31
jkwipr19-May-04 9:31 
GeneralRe: Q from a novice Pin
Jon Sagara10-Sep-04 7:25
Jon Sagara10-Sep-04 7:25 
Questionroot directory? Pin
roguedis17-Mar-04 15:56
roguedis17-Mar-04 15:56 
AnswerRe: root directory? Pin
Jon Sagara19-Mar-04 12:31
Jon Sagara19-Mar-04 12:31 
GeneralRe: root directory? Pin
roguedis20-Mar-04 23:37
roguedis20-Mar-04 23:37 
GeneralRe: root directory? Pin
Member 13392487-Sep-04 2:17
Member 13392487-Sep-04 2:17 
GeneralRe: root directory? Pin
Jon Sagara7-Sep-04 8:21
Jon Sagara7-Sep-04 8:21 
GeneralFew more suggestions Pin
Kant4-Jul-03 5:46
Kant4-Jul-03 5:46 
GeneralRe: Few more suggestions Pin
Jon Sagara5-Jul-03 5:33
Jon Sagara5-Jul-03 5:33 
GeneralNice! Pin
Ravi Bhavnani4-Jul-03 3:36
professionalRavi Bhavnani4-Jul-03 3:36 
GeneralRe: Nice! Pin
Jon Sagara4-Jul-03 5:29
Jon Sagara4-Jul-03 5:29 
GeneralFew suggestions Pin
Snakebyte3-Jul-03 20:02
Snakebyte3-Jul-03 20:02 
Hi,

Good Job.

I've few suggestions. If you really want people to use your tool, you need to get rid of those two requirements that you have mentioned in your article. Lets talk about them.
<br />
Your collection contains entire CDs and is arranged by artist and album (see "Directory Structure" below). <br />

Your solution needs to be generic. What don't you read the artist, title and album information from the Id3 tags. You can read either ID3v1 which are fixed length and easier to decode or ID3v2 which are of variable length and can contain any information(even Album Cover as image). You can find more information on this from http://id3.org/[^]. Include ID3 library in your code and extract all the required information from any provided Mp3 file.

In-case your MP3 files does not contain ID3 tags but are organized in proper directory structure, then you can convert that information into Id3 tags using many of the MP3 tools freely available on the net. My favorite is Music Library. This this the most powerful MP3 organizer that there exists. Check it out
http://www.wensoftware.com/MusicLibrary/[^] (But unfortunately it is not free. You can try their 30 dayz eval copy. I'm sure you'll be impressed.)

<br />
Your collection resides on a machine capable of being a Web server. <br />

Hmm... I'm not sure of this and I haven't seen your source code. Unless you are using ASP or any other server side scripting. Web-server should not be a requirement. You do not need Web-server to see html files. HTML files can be seen from the local harddisk as well. Instead of asking for Hostname and virtual directory simply ask for the directory where the output HTML file is to be placed. And then you can see your MP3 collection by pointing your browser to the generated file (eg c:\MP3\My Collection.html) You may even make this as your Home Page.







I'm too geeky for this shirt,
too geeky for this shirt,
so geeky that it Hertz!


GeneralRe: Few suggestions Pin
Jon Sagara4-Jul-03 5:39
Jon Sagara4-Jul-03 5:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.