Updated 6 November 2007
I bought an iPhone and I'm pretty happy with it but there's one problem: it's too small to hold my entire iTunes library. I'm already using my Mac as a web server and I'm usually home or somewhere with wireless access so I figured ot a way to have all of my songs available to me at all times. I don't have much time right this second to give a lot of detail so I'll give a quick overview of what I'm doing and flesh it out later. Comments or questions can be sent to me at firstname.lastname@example.org.
Update: I fixed the script so it works if your folders have ampersands ("&") in them. Download 1.01 now.
This is pretty simple if you're already familiar with running a PHP-enabled web server on your Mac. Standard disclaimers apply: if you get your machine hacked because you're running a public websever, or if the RIAA learns that you've got all your music in a world-viewable directory, or if your ISP cuts you off for doing this, it's not my fault.
Even if you don't have a world-accessible server, you can still use this to make your music available on your wireless LAN at home or work. Just go to your computer's LAN IP address or Rendezvous name (yourcomputername.local) instead of a regular URL.
Basically, all I'm doing is making the iTunes music directory available to the web server, creating a nice start page with buttons, and then creating a directory listing. (This is done because iPhones cannot see "shared" iTunes music, nor can they connect to a shared network drive.) You can use Apache's built-in directory index feature, but what's nice about this, besides the pretty buttons on the front page (which were carefully sized and arranged to fit perfectly on the iPhone's screen, either in portrait or landscape mode), is that the listing pages themselves are sized for the iPhone, so you don't have to zoom in and out to use this.
This is still under development, so there are some problems. Some characters might cause links to fail. I haven't tested it with every type of audio file, purchased music, etc., so I'm not sure if all of those work yet. This is just a hobby for me and it does what I need it to, so updates won't be frequent.
There are also some limitations. This is not a world-class iTunes front-end. All it does is show you your music as it exists on your hard drive. There's no searching, sorting, filtering by year, playlists, etc. When you click a letter on the main screen, you'll see an alphabetical listing of artists. Clicking on an artist's name will show you an alphabetical listing of their albums. Clicking an album will show you an alphabetical listing of tracks. (These will not be in the proper album order, unless you name your songs with the track number at the beginning.) This is not searchable or sortable. All this does is give you access to any song, assuming you know where to find it.
This might not work if you're password-protecting your music with an .htaccess file. Once upon a time it didn't work, then Apple fixed it, then they broke it again. I think it's working now but I can't say for sure.
So, let's get down to business. Here's what you'll need to do.
And that's it! You should now be able to go to http://your.server.name/iphone/, (be sure to have a slash at the end of the address--i.e., /iphone/, not just /iphone), see the icons, and navigate to a song. When you click on a song, it will start loading, and when you press 'play', it will start to play. When you're done, press Safari's "back" button (NOT the '|<<' (previous track) button) and find another song. One nice thing is that, once the song starts playing, pressing the power button will turn off the screen but the song will keep playing.
If you have AAC files (extension: m4a) and they aren't playing, enter these four
commands, one at a time, into Terminal:
sudo chmod 777 /etc/httpd/mime.types
sudo echo "audio/mp4 mp4 m4a m4p" >> /etc/httpd/mime.types
sudo chmod 644 /etc/httpd/mime.types
sudo apachectl graceful
sudo chmod 777 /etc/apache2/mime.types
sudo echo "audio/mp4 mp4 m4a m4p" >> /etc/apache2/mime.types
sudo chmod 644 /etc/apache2/mime.types
sudo apachectl graceful
That should make it work.
I have a demo site here. (Note: THERE ARE NO MP3s ON THIS SERVER. The links just lead to empty placeholder files.) If you're not reading this with an iPhone, you should use Firefox to look at that--Safari won't let you make the window small enough to simulate an iPhone's screen in Portrait mode.
Questions? Comments? Any other feedback? Here I am.
PS: If you thought this was cool, check out my other page on how to put iPhoto's new 'skim' effect into your own web gallery.