A few people have asked me how I configured things to get an MP3 playlist in my sidebar. I figure that it’s worth explaining once here in a tutorial.
First, let me note some parameters:
- I accomplish this with a copy of WinAMP [version 5, to be exact], a WinAMP plugin called DoSomething from OddSock.org that was originally designed for Shoutcasters, and an FTP login to my site. This isn’t a WordPress plugin, and until I develop the system I’m wanting to develop, it wouldn’t be. [Of course, the system I want to develop is far more massive in scope than simply showing the last three songs I've played on my MP3 file list at work.]
- This is not a drag-and-drop solution, but it is pretty workable.
- I don’t know how to do this with other MP3 players. I know that plugins exist for them, but I personally do not use them, so I am of no help to you.
The process of installing WinAMP and DoSomething is beyond the scope of what I’m working towards here, but from there, the process is pretty simple. You will need a place on the local hard drive to put two files: one is the file with the template that DoSomething uses to create the Now Playing list, and the other is the file that is repeatedly generated by DoSomething. I suggest creating a small subdirectory somewhere that you’ll know on your hard drive for this; that way, when you see these files, you’ll remember that they shouldn’t be deleted.
The hardest thing is setting up the template file. Here’s what I have:
<ul> <li class="nowplaying">Currently spinning: "%%CURRENTSONGTITLE%%" by %%CURRENTARTIST%% on <em>%%CURRENTALBUM%%</em></li> <li class="nowplaying">Before that: "%%SONG2%%" by %%ARTIST2%% on <em>%%ALBUM2%%</em></li> <li class="nowplaying">And before that: "%%SONG3%%" by %%ARTIST3%% on <em>%%ALBUM3%%</em></li> </ul> <p>Last updated: %%LASTUPDATED%%</p>
This file is saved locally as last-spun.txt. The output file that I create is called last-spun.inc, to keep up with the PHP convention of .inc files for files that are included without interpretation—that is, the PHP processor doesn’t process them. It’s just text.
Now, you have three things left to do:
- Get WinAMP to run DoSomething on this template file to update it with every song.
- Get DoSomething to FTP the file to your server.
- Get WordPress to include the file.
The first two steps require that you go to configure DoSomething. You’ll have to go into WinAMP’s preferences and select DoSomething as the plugin that you want to configure.
You will need to have two actions set up by the time you get this complete: Generate an HTML Playlist and FTP A File. You can see below that I have both of these set already and in that order.
First, you need to get DoSomething to generate an HTML playlist from the template file that you just used. You’ll have to point to the raw template on the first line, and then give a name for the desired output file on the second line. Please note that my file-naming convention is inconsistent with the above; I used a .php on the in where you will use a .txt. The file extension has no bearing on what you’re doing locally, and is a remnant of my learning process with DoSomething.
With the playlist generated, DoSomething now needs to stick it on the server.
Don’t let my differing FTP login and all fool you.
The third and last step it requires you to edit a WordPress file. Don’t freak out, though; it’s pretty simple.
You will want to go into the menu div of index.php and add the following wherever you like inside the unordered list that contains the entire menu:
<li>Now Playing:
<?php include('/home/rmfoblog/public_html/[DIRNAME]/last-spun.inc'); ?>
</li>
[DIRNAME] should be replaced with the name of your RMFO-Blog directory, such as about.
Save index.php and you’re golden.
Let me know if you have questions.
[UPDATE: The text has been re-written slightly to accomodate the screenshots that have been added. I hope that this helps. I have also made changes to each of the code snippets to fix small errors.]
i’m getting an error…it’s telling me:
Parse error: parse error, unexpected ‘/’ in /home/rmfoblog/public_html/david/index.php on line 70
David:
1. I had a stray closing li element in the second snippet, which I’ve now fixed.
2. I’m willing to bet that WinAMP outputted a slash in the file; an unescaped slash isn’t going to parse correctly. Your MP3’s ID3 tagging has slashes in it, likely.
i’m having problems. i did all that you said to do…and still the column is all jacked up, and i don’t know how to fix it.
please help!!
There seem to be questions on how to work this. I was hoping to avoid making screenshots, but I’ll do that tomorrow.
I am an idiot … I have corrected the last snippet. You’d think that with as many include() statements as I’ve written than I would catch that. Yeesh.
**UPDATE**
I got mine fully working. When you’re creating the .txt file, remove the space between “LAST” and “UPDATED”..so the last line reads:
Last updated: %%LASTUPDATED%%
Yeesh … I should’ve caught that, too. I’ve fixed it now.
**UPDATE**
Yeah, these comments allow HTML (duh Steve!!)…so remember to couch that last line in the “p” brackets that are there in the code snippet.
iTunes (Windows-only) Plugin
For those seeking to, in some way, have a playlist in their sidebar like what I described with WinAMP and DoSomething, there is now a iTunes plugin for WordPress that uses a Windows-only bit of software on the client side. Since most rmfo-bloggers tha…
[...]
Winamp Feed
Tuesday 3 May 2005 @ 3:06 am
Oh yeah, I also added a winamp feed, so if you wa [...]