This post originated from an RSS feed registered with .NET Buzz
by Dan Fernandez.
Original Post: Good Question on WMA support for Windows Forms
Feed Title: Dan Fernandez's Blog
Feed URL: /msdnerror.htm?aspxerrorpath=/danielfe/Rss.aspx
Feed Description: Dan discusses Dot Net.
J. Daniel Smith in the comments to my last post writes: “ Why doesn't the new Sound control support WMA files? (Yes, I know it's just a wrapper around the Win32 control...)
But still, this "mixed messaging" from Microsoft is a bit annoying at times: use WMA (and not MP3)...unless you want to embed it in your application, then you have to use WAV.“
Response:
Very good questions, and I have to give a good response to someone with “Daniel“ in their name:) You are correct, the sound control does not support wma files (or MP3 file for that matter).
Since I don't work on the team that built that control, don't consider my answer definitive (someone from that team, feel free to chime in here), but I'll give you my best guess.One of the issues with playing sound files is that you need the codec that translates bits into music, and each music file type will have its own.For example in MP3 files, you must license the codec from the Franhofer institute which owns the patent for MP3 (also known as Moving Picture Experts Group Layer-3 Audio), and this codec is currently in Windows Media Player, not in Windows.
For wma files, again Windows Media Player is the application that contains the codec and not Windows itself. Rather then discuss how great it would be from a development perspective if you could assume that Windows OS had better support for great sound codecs built-in, (was there a lawsuit about us adding more features to Windows?? Nah, everyone loves us), I'll stop here and tell you how you can solve this issue by using Windows Media Player:
What do you do if you want to play a WMA file in your Windows application?
You can easily play wma files by drag/dropping a Windows Media Player control onto your application, which will add the ability to play files just like WMP, and even includes other WMP features like playlist support. This is done by adding a reference to the control - right click on the toolbox, select add items, select the COM tab, and scroll down to Windows Media Player (for reference it's at: “C:\windows\system32\wmp.dll“).
I've included some links to code samples using WMP, including some by Duncan and Eric.