Register   |   Login

 

Spark Your Solution

 Scott's Technology Blog Minimize

Feb 22

Written by: Scott Davis
2/22/2009 10:01 PM

SilverLight doesn't support WAV files, yet.  So what happens if you want to play a WAV from Silverlight?  Well, if you can play a WAV from Javascript, you can play it from SilverLight.
 
Through a quick web search I found this nice reference.
http://www.phon.ucl.ac.uk/home/mark/audio/play.htm

Using the code from #6, I inserted this code into the HEAD tag of the host page.

Add this code to the HTML inside the FORM tag.  

In the code behind of your SilverLight application add this using statement, to allow access to the Browser's DOM

Whenever you want to play a WAV, run this code.

Don't forget about the issue with accessing resources on domains other than your own.  You many need to include a clientaccesspolicy.xml in your website.  But that is a topic too large for this post.

There are many ways to improve this code.  Error handling, create a wrapper method in Silverlight, and use another javascript method to preload the WAVs before you want to play them.  But this should get you started, should you need to do it.

Tags:

Your name:
Title:
Comment:
Add Comment    Cancel  

  
 Blog Dates Minimize

 Print   
 Search Minimize

 Print