Tuesday, August 17, 2010

How to play a folder with mp3 files in Mac OS X

Update: Not working anymore.

I am not sure about other Windows users but I am very used to surfing around my hard disk in Windows Explorer and select one or more folders (representing albums or artists), then right-click on them and choose the "Play in Winamp" menu. Unfortunately the mighty Winamp is not available on Mac (it may have something to do with the name ;)). Of course, you may install a third-party media player for Mac but I decided to go with the iTunes since it is an all-in-one solution for media organization, playback, purchasing as well as iPhone/iPod synchronization and is bundled with Mac OS X. Furthermore the playback can be controlled via the special keys on my MacBook Pro.

Before sharing my solution, I would like to explain how iTunes is set to work by default and why it requires a special solution. Since iTunes is actually more than just a player and since the whole concept of Mac OS X is projected towards inexperienced users, it imposes a specific usage which is different than what people are used to on Windows. iTunes keeps a library of all the media files you have downloaded from the iTunes store or imported from hard disk. Even if you have already downloaded files on your hard disk, you must import them in iTunes prior to playing them (or uploading them to an iPad/iPhone). It organizes the music in a great way: by artist, album, genre, etc., so it is easily searchable and you can create playlists. Unfortunately this approach is iTunes-centric, i.e. you have to open iTunes and start from within there if you would like to listen to music. That's opposite to my typical Winamp usage which is Windows Explorer-centric: I go to my music folder(s) on hard disk and choose the music to play which is then open from within explorer to Winamp.

By default, when importing media files to iTunes library, those files are copied to a specific folder used by iTunes (UserHome/Music/iTunes/iTunes Media/Music). That feature has been designed towards most user who are not organizing their music and download single tracks obtained from here and there. iTunes copies the files in that specific location by organizing it neatly in artist and album folders. However, there are people who already have huge libraries of music on their hard disks. If you import those files in iTunes, you will end up having two copies of each file - one in the original location and one copy in that folder mentioned above. That's pretty stupid, confusing and impractical. That sole fact made me curse iTunes for about an hour :)

So, here is the whole solution (so far tested on Snow Leopard only) of having your existing music files played by iTunes in a right-click from within Finder (plus disabling the stupid file duplication):

1. Start iTunes and open its preferences dialog (by pressing Cmd-,)
2. Click on "Advanced" and uncheck the following two checkboxes:
- Keep iTunes Media folder organized (I think this option is taken in mind only when the checkbox below is checked but I am removing it just in case)
- Copy files to iTunes Media folder when adding to library - the culprit for having duplicate files!
3. Get this file: Play in iTunes.workflow.zip and extract it in UserHome/Library/Services (If you don't have this folder, you have to create it. For Leopard the folder is named differently, so I will have to check that and will update this information when I have it).

That's it! Now you can select multiple files and/or folders, right click on them in Finder and choose the "Play in iTunes" menu.

Please read! Here is how this works. The workflow file is a file I have created in the Automator application bundled with each Mac OS X and that's actually a great application! You can create a lot of automated common tasks to start from within Finder or scheduled on a date, etc., and the best part of it is that most workflows wouldn't require any programming skills, you would just combine different commands you choose from a list. In my case the workflow creates a new iTunes playlist called "On the fly" (So, make sure you don't have a custom playlist with the same name because it will get cleared each time which required an ApleScript btw). If the selected music has not been imported in iTunes previously, it will be imported (the files will not be duplicated, they will be analyzed only for gapless playback which may take some time the first time you play/import them) and then added to that playlist and played. Please note that if you have selected many folders which have not been previously imported in the library, that can take some time to import and the playback may not work the first time. Next time it will be OK.

Hope that helps! Any feedback and suggestions are welcome :)

No comments:

Post a Comment