FEED TWITTER

How to Build M3U and PLS files (playlists for audio files)

Okay, so that might be the geekiest blog post title ever but I don’t know how else to say it. The situation is this: You have a client and they need to upload an album for download. Whether it’s a paid download or free doesn’t really matter at this point. You’re going to need this process to be as foolproof as possible so you should include both the M3U playlist to cover non-iTunes users and the PLS file format to cover iTunes and Windows Media Player users. This way your end user will be able to click these files and a playlist or album will be created in their software program or the playlist you determine will start to play immediately in their audio program.

You’re going to need to gather some info about your MP3s in order to build these files. Here’s what you need:

  1. Artist name
  2. Title of each track
  3. Length of each track (in seconds – multiply the number of minutes by 60 and add the seconds to it. So 4:22 would be 262 seconds)
  4. Full file name for each track (ex. Overview.mp3)

Okay so let’s build our files, M3U first. According to Wikipedia, the file starts out like so:

#EXTM3U

#EXTINF:41,Artist Name - Track Title
filename.mp3

So for the additional tracks in this file you just cut and paste the example above (except that opening line (#EXTM3U that tells your software what kind of file it is), the #EXTINF: will stay for all files, the 41 is the track time, artist name, hyphen, track title, line break, filename are all kind of self explanatory. It needs to be in this format including the hyphen and line break. Then skip a line and paste your next one in.

For the PLS file things are pretty similar. Here’s what it looks like for a two track playlist:

  [playlist]

File1=01_Overview.mp3
Title1=Overview
Length1=41

File2=02_What_is_Meditation.mp3
Title2=What is Meditation
Length2=287

NumberOfEntries=2

Version=2

So things look pretty similar here. Filename, title, length in seconds. Then you tell how many entries were in the list and it has to be Version=2 for some reason. Again, Wikipedia has the scoop on this but this will get you started. Copy and paste tracks like you did before and duplicate the line breaks like I have here.

Here’s the key to both of these files as far as keeping it simple for your user: Zip all of your files together and include the M3U and PLS file in that zipped directory. Why? I know Wikipedia doesn’t tell you to but the thing is, when your user downloads the files, you don’t really know where they are going to be saved. By zipping the files up, you make sure all the files will be in the same place as your playlist files. So, when the user clicks one of the playlists, the player will look for the files RELATIVE to where your playlists are, and since they’re in the same directory they’ll work correctly :)

PeachPit (Pearson Education)

Mar 8, 2010 / Blog / Web Design / , , , ,