media, music, windows comments edit

The iTunes COM for Windows SDK seems to have been moved from the location they originally had it - http://developer.apple.com/sdk/itunescomsdk.html. It is now inside the Apple Developer Connections site and you need a free membership for it.

Once you have your membership and log into the ADC site, go to Downloads -> Developer Tools. About 1/3 of the way down the page you’ll find the iTunes COM for Windows SDK.

(You’ll need this if you want to write scripts or programs to automate iTunes from Windows. It used to be really easy to find, but now it’s buried, so here’s a pointer.)

media, music, windows comments edit

While it was not my primary goal, one of the things I thought would be a “nice to have” in my Windows Media Center solution is the ability to play my music through the Media Center interface. The big wrench in the works there, though, is that I primarily use iTunes to manage my music and much of it is in AAC and Apple Lossless formats. Due, I’m sure, to some ridonkulous licensing crap, Windows Media Center does not play either of those formats natively, so getting my music in there looked like it was going to be painful.

The Goal: Get my music into Windows Media Center.

Requirements:

  • As few moving pieces as possible. That is, if I don’t have to have a script that runs a sync operation that happens on a scheduled basis or something, I don’t want it. This is similar to the “simple, simple, simple” goal I mentioned in my Media Center overview.
  • All music playable except the DRM-laden tracks. I want my entire library available, not just a subset of the tracks. That said, since I have very few purchased tracks from iTunes, if I can’t play the licensed music due to DRM issues, that’s OK. Out of like 13,000 tracks, I think like 10 or less have the DRM on them. (I have a lot of CDs.)
  • Metadata visible in Media Center. At the very least, I want to see album title, track name, artist, and the cover art. Nice to have would be the year, genre, etc. but I don’t normally navigate by those things.
  • Playlist import is optional. I have several playlists in iTunes but I’m not necessarily glued to them. If they don’t make it to Media Center, I won’t be heartbroken.

Options:

Given all that, I basically have two options that I found.

  1. Buy MCETunes. MCETunes is a plugin that you install that syncs up with iTunes (on the same machine as the Windows Media Center) and updates the Media Center library with entries for iTunes music. It syncs up your playlists, too, so those are there, and when you play the songs, it’s actually [somehow] wrapping iTunes. A lot of folks are using it and like it, but there are some forum posts that make me a little wary about the whole thing. Lots of moving pieces.
  2. Get Windows Media Center to play iTunes music natively. This is a little more manual work, but it means enabling AAC and Apple Lossless for play directly through the Windows Media Center interface. No playlists, and maybe less metadata than with MCETunes.

The road I went with was getting Media Center to understand AAC/ALAC (Apple Lossless) natively.

How To:

Here’s how to get Media Center working with your iTunes music. For these instructions, I’m using Windows Media Player 11 on Windows Vista Home Premium. (The Windows Media Player info is important because Windows Media Player and Windows Media Center share the same library. If WMP indexes a file, it shows up in WMC.) You will also need Administrator privileges because you’re going to be installing stuff.

As with everything, this is all at your own risk. If it doesn’t work for you, if you hose your machine, if you end up launching a nuclear attack on a neighboring country… that’s all on you.

Also, it may be handy (if you index something you don’t want or want to “clean out” your Media Center library) to know how to totally flush the Windows Media Player library and start from scratch. I had to do that a couple of times before I got it right.

Read all the instructions before you start. It will help to understand the whole process before you start in. You don’t want to get halfway done and have an “oh crap” moment.

With that…

  1. Make sure the “album artist” field is filled in on all of your music. This is just good metadata practice, but it will come in very handy later because “album artist” is how Windows Media Player gets album artwork and deals with other metadata issues. I have a script that may help you with that, but it is a lot of work if you have a lot of tracks.
  2. Get the DirectShow filter. A DirectShow filter is how you teach Windows Media Player/Windows Media Center how to play a new file type. DSP-worx has a filter you can download for free that will enable AAC/ALAC playback. You can download it here.
  3. Install the filter. Create a folder on your primary OS drive. Make sure it doesn’t have any spaces in the pathname or it may not work. I made mine “C:\dsp-worx” - you may want to as well. Once you have that folder, unzip the contents of the DirectShow filter zip file you just downloaded into that folder. In there you’ll see a “register.bat” file - double-click to run that. That registers the DirectShow filter with Windows so now you can play AAC/ALAC files. But you’re not done yet.
  4. Fix up Windows Media Player metadata downloading. Media Player handles automatic downloading of metadata in a weird way that can sometimes mess up the metadata you already have on your files. Go to Library -> More Options… in Windows Media Player. Now you need to make a choice about whether you want Media Player to “augment” your iTunes files with metadata it thinks it needs or if you want to manage all of it through iTunes.
    • If you want Media Player to download data (this is not what I did)…
      1. On the “Player” tab in “Options,” check “Connect to the Internet.” This has to be checked for the player to be able to connect and get the data.
      2. On the “Library” tab in “Options, check “Retrieve additional information from the Intenet” and select “Only add missing information.” That will allow Media Player/Media Center to augment the metadata on files in your library with stuff it downloads.
    • If you don’t want Media Player to download data (this is what I did)…
      1. On the “Player” tab in “Options,” uncheck “Connect to the Internet.” Doing this stops Media Player/Media Center from automatically connecting to get metadata.
      2. On the “Library” tab in “Options, uncheck ”Retrieve additional information from the Intenet.” This will stop Media Player/Media Center from changing anything on your music files.
  5. Fix other Library options. There are some options you’ll want to make sure are fixed up before you start indexing iTunes music. Go to “Library -> More Options…” in Windows Media Player and make sure you’re looking at the “Library” tab.
    • Don’t let Media Player delete your stuff. Uncheck “Delete files from computer when deleted from library.” If you don’t do this, then Media Player will delete files out from under iTunes when you manage your files in Media Player/Media Center.
    • Don’t let Media Player move your stuff. Uncheck both “Rename music files using rip music settings” and “Rearrange music in rip music folder, using rip music settings.” If you leave either of these checked, Media Player may move your music around out from under iTunes.
    • Decide on where to maintain ratings. I maintain my song ratings in iTunes so I don’t need the ratings in Windows. I unchecked the “Maintain my star ratings as global ratings in files” option. You may want those ratings. If so, check that option. I don’t think it hurts either way, I just didn’t want to hassle with it. If you leave it unchecked, the ratings only persist in the Media Player library database.
  6. Download the tag extender. A tag extender is what allows Media Player to read/index the metadata tag information (title, artist, etc.) from the AAC/ALAC files. I’m using this one from Softpointer. I tried this one on Sourceforge but didn’t have as much luck with it. Maybe it was just me. The Softpointer one also handles a ton of other formats, so big ups there, say, in case you want to add FLAC or Ogg Vorbis support later.
  7. Install the tag extender.Whichever tag extender you just downloaded, install that bad boy.
  8. Reboot. I’m not sure if this is entirely necessary, but I did. Can’t hurt. You just updated WMP/WMC to understand how to play a new file type and read those metadata files. I’m sure something is cached in memory somewhere that will be hosed up if you don’t reboot, so start that and go get a refreshing Coke.
  9. Tell Windows Media Player to index your iTunes music. I think you can technically do this from either WMC or WMP, but you get more instant results and a better progress bar in Windows Media Player so it’s easier to do it there. Since WMC and WMP share a library anyway, one is just as good as the other. In WMP, go to “Library -> More Options…” and, on the Library tab, click the “Monitor Folders…” button. Follow the prompts to add your iTunes music folder to the library. (If it’s already there, you may want to remove it and re-add it to force the reindexing of the folder.)
  10. Wait. Depending on the number of tracks you have, it may take a while.
  11. Enjoy. It should have found all of the *.m4a tracks (AAC/ALAC) that were in the folders and they should show up in the library. Double-click one - it should play. You should also, at a minimum, see the track title, album title, and artist on there. If you fire up Windows Media Center, the same information should be present.

Postscript - Album Art:

My experience was that the album art didn’t automatically make it through when I indexed my tracks. There are a couple of things you can do about that.

  1. Easy but painstakingly slow: You can right-click on each album in the library that doesn’t have album art and select the “Find album art” option. From what I can tell, this downloads the album art and stores it in the WMP database. (For a while I thought it was downloading the album art and saving the images in the folder with the music as hidden files named “AlbumArt_{LONG-GUID-HERE}_Large.jpg” and such, but after reindexing a couple of times, I’m not finding those files. I can only surmise they’re in the library.)
  2. Faster but more work up front: If the cover art is stored in a file called “Folder.jpg” in the folder along with the songs that make up the album, the album art will be assumed to be that image. (This is the same as how the DVD Library works.) If all of your tracks have album art, you could write a script using the iTunes scripting interface that goes through each track, figures out what folder it’s in, and if there’s no “Folder.jpg” in there, have it extract the album artwork from the track and save it as “Folder.jpg” in that folder. When the scheduled/background indexing process runs to update the WMP/WMC album art, it’ll find this image and automatically update the displayed album art.

I’m taking the scripting route, but I haven’t written the script yet. I’m still assigning album art to my tracks so it’ll run without any hitches. When I have the script written, I’ll be sure to post it.

Anyway, that should do it - you should be able to play your iTunes music natively in Windows Media Center.

Other articles you might be interested in:

No, I did not watch the Chronic-WHAT!-cles of Narnia.

What I did, though, is accomplish quite a few things on long-running projects and had quite a bit of time to relax, so big win on both counts. I’m pretty goal-oriented so it’s nice to check things off the list of things to do, and yet, I’m also really lazy so “doing nothing” is one of those things I like to check off.

Saturday was my day to accomplish stuff. The two items I got to check off my list of ongoing crap:

  1. I got my recliner fixed. Jenn and I bought some nice La-Z-Boy recliners for our game room upstairs. When they arrived, we noticed that one was really comfortable, but the other felt like you were sort of sitting in a hole on one side - you weren’t sitting level, more at an angle or something. We had the repair people come out and look at it, and there was a piece that wasn’t stapled down right so they fixed that. I sat in it, though, and it still didn’t feel right. I had some other people come over and try it, too, just to make sure I wasn’t being all “Princess and the Pea” with it and, sure enough, it wasn’t just me. The repair folks came back on Saturday and added some padding on the low side to reinforce the seat. Now it feels great! One less thing to worry about.
  2. I figured out how to play iTunes music through Windows Media Center. I’ll actually post a separate blog article on this later, but I figured out how to get Apple Lossless and AAC music playing through Windows Media Center just like MP3 files, and it didn’t require me to buy/install anything like MCETunes. Music was not my primary goal with my Media Center solution, but getting it to work makes me feel good.

Saturday night I had my friends Jason and Torin over to play some games. We originally planned on busting out some Colossal Arena but somehow we ended up playing Left4Dead for like four hours. Good times - even Jenn joined in on the zombie destruction.

Sunday was truly lazy and relaxing. Jenn and I took a bike ride to the Starbucks in downtown Hillsboro where I sucked down a giant Frappuccino, thereby negating any good the bike ride would have done. We watched some movies, had a little lunch, then around 4:00p Jason and I reconvened online for some more zombie mayhem. I rounded off the night with a very tasty barbecue meal Jenn made. Good times.

books, net comments edit

I just got finished reading through ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008 by Vince Varallo, and I came out fairly underwhelmed. I read through this book thinking, with a title like that, it would take me through creating an enterprise-class application, complete with all of the things one would think are a part of such an app. As it turns out, I think the title should be something more like “Introduction to N-Tier Development in ASP.NET.”

Each chapter is set up in the same format, and it’s a decent format - outline the problem, explain the design, implement the solution. The chapters are:

  1. A Framework for Enterprise Applications
  2. The Data Access Layer
  3. Designing the Business Logic Layer
  4. The User Interface Layer
  5. Exception Handling
  6. Role-Based Security
  7. The Workflow Engine
  8. Notifications
  9. Reporting
  10. The Query Builder Control
  11. The Dashboard
  12. Auditing
  13. Code Generator

If you go in never having built a multi-tier app where you separate your data access from your business logic and your UI, this is a good intro to that. The explanation of the separation and showing how to keep those things separated is a good education for the ASP.NET developer who has only ever just thrown a DataSource on a page and let the controls do the work.

If you have any experience with multi-tier apps, though, the goodness, unfortunately, is not to be found. Even if you have a light amount of experience, I probably wouldn’t recommend this book since it could do more damage than help. There are several reasons for this.

First, there are little things through the code that are just bad practice.

  • The naming conventions for everything in this book are absolutely horrible. “ENTBaseBO” is the name of the base class that all enterprise business objects derive from. The names only get worse and more unintelligible and distracting from there. When cruising through the method bodies presented you sometimes wonder if he’s using Hungarian notation in C# and then you realize that it’s just bad naming.
  • Almost every exception that gets thrown in the code is the generic System.Exception type. Even if a more specific exception type would be more appropriate, it’s always a general Exception.
  • Rather than overriding the ToString() method on business objects, a new “GetDisplayText()” method gets added in one of the myriad base classes which gets used throughout the book when displaying the object in UI. (Not a showstopper, but it’s Just One More Thing that didn’t make sense.)
  • The data access layer uses the Microsoft Patterns and Practices Data Access Application Block, which is good… but the book urges you to use an old version of it “because it’s simple to use and easy to understand” - even though the new one has many improvements over the old.

Larger things start creeping up on you once you get past the smaller stuff.

  • There’s no localization and no mention of it. Every string seen in any UI is hardcoded somewhere in the system (not necessarily just in the UI) rather than being stored in resource files. Even if you only plan on supporting one language, it’s still good practice to separate your strings from your code.
  • There are no tests anywhere and no mention of them. We’re building an enterprise application and we’re not going to test it? Really?
  • Rather than use standard functions built into ASP.NETlike the SiteMapProvider and navigation controls that can bind to it, a lot of effort goes into writing your own site map management system and custom controls to bind to that proprietary system. Role-based security that doesn’t hook into the RoleProvider.
  • Chapter 7, on “the workflow engine,” is almost 100 pages showing you how to write a proprietary state machine workflow system. I actually had to flip back and look at the cover to make sure we were in .NET 3.5, then I got really curious as to why this wasn’t a 10 page chapter showing how easy that sort of thing is to implement using Windows Workflow Foundation, which comes for free with the .NET framework.
  • Why is the “code generator” chapter about creating a Visual Studio wizard but has no mention of T4 or any third-party code generator? With all the code generation options out there, would I really want to roll my own using StringBuilders?

Other stuff just sits in the background and bugs at you more subconsciously. The code snippets in places are inconsistently formatted and hard to read. You start wondering why there’s a little bit of logic in stored procedures and a little bit of logic in the data access layer and a little bit of logic in the business layer and whether there might have been a way to break that up in a way that would be more maintainable. No mention at all of design patterns. No mention of MVP or MVC.

Long story already too long, if you’ve never written an n-tier application, if you’re used to just creating a single web application project that just has pages in it that were created in the Visual Studio designer and that’s it… this book will give you some ideas about how to change the way you look at your application’s structure and separate the logic out of the codebehind of your pages into different layers. If you have written any sort of n-tier application before, this is most likely not for you.

[Postscript: While writing up this review, it reminded me of the recent Jim Holmes blog post challenging MS Evangelists to present real examples with tests rather than just highlights. This book felt like one of those presentations - show you the rough idea and general concepts, but not the full “real world” view with good patterns and practices.]

UPDATE 3/15/2010: I got several questions about what book(s) I do recommend for learning enterprise app development so I posted a short list of recommendations.