Silverlight, WCF REST and Streaming My Personal Music Repository from a Standalone EXE
This is way cool. From time to time, I tend to screw around with stuff I enjoy that really has little productive value. A year ago this month, I recall wanting to continue writing about sharing your personal music without using IIS and hosting the music directly from a WCF standalone executable. Well it turns out this is a whole lot simpler than I originally thought.
Disclaimer: This probably isn’t best practice, and it’s ripe for enhancements. My hope is that it gets your imagination fired up and motivates you to continue where I left off.
Challenges:
- How the heck do I stream an MP3 file to a media element via WCF (without having to download the whole file before playing it)?
- Cross-site scripting policies are blocking my download requests. How can I serve these up via my self hosted WCF REST service?
- Silverlight3 doesn’t support WCF REST yet. How do I deserialize the WCF REST contract messages?
Changes Since Last Release
My original design was very simple. I hosted the Silverlight files and used WCF with an IIS server at home. The player pulled a list of files and locations. The player’s media element source was set directly to a music file hosted in an IIS virtual directory. All that works great until you are on a machine without a web server. Ultimately, I wanted to figure out a way for the user to host their music repository from their desktop with a simple executable and port forwarding. Which means it would have to serve up all the resources necessary to run the Silverlight player. It would also have to serve up the WCF services and actual music files themselves.
Since the last post a year ago, I’ve made quite a few little tweaks to the player like: regular expression search, random songs, random play order, and a volume control. I also integrated a compact SQLite database for searching so the server-side doesn’t have to do a file system search for each request.

