Using WMP and Quicktime in Silverlight (Revisited)

November 6, 2011 at 10:34 am | Posted in Silverlight | 1 Comment

In 2007, I was working on a Silverlight application in which I wanted to change the rate of speech playback without affecting the pitch.  At that time, the media element available to Silverlight did not have a rate control while Windows Media Player works wonderfully for mp3 files.  I found that I could actually use WMP in a Silverlight application by embedding the player in the HTML file that hosted the Silverlight control and then controlling the player by using a bridge between managed C# and JavaScript.  The technique was documented in this blog post.

Since then, changes to Silverlight and browsers that have broken this code.

I resurrected the old code base and ported it to Silverlight 4.  The code can be tested here.  And you can download a zip file of the web project here.  The code is still a bit dated and ‘hackish’ but has been tested on IE9, Chrome 15 and Firefox 3.6 with the WMP plug-in installed.  For some reason, the volume control does not work in Chrome.  I also forced Chrome to use the Quicktime player instead of WMP.  It works, but Quicktime does not preserve the pitch when the rate is changed so it will sound weird at slow speeds.  I did not test on a Mac.

Silverlight 5 is supposed to have a new media element that has a rate control function.  If it works as well as WMP, then this approach will no longer be necessary.

Blog at WordPress.com.
Entries and comments feeds.