Geeks With Blogs
Catherine Russell Architect, President of "Women In Information Technology" Group
Technorati Tags:

If you want to play music or a short sound clip in Silverlight here is what you need to do:

1. Your sound file
First, make sure you sound file is MP3 or WMA format as other formats are not supported.Save your file to ClientBin folder (where your xap file gets coppied when buiding the project). If you dont want to store your file to the ClientBin folder do this: from Visual Studio right click on the sound file and select Properties. Now in Properties window change Build Action to Resource. This ensures the file gets copied to the ClientBin folder during execution.

2. Add a MediaElement in your Xaml file. Set the Source to be the name of your file and AutoPlay to False so it can be played at click of a button. Also add a button to play the sound when clicked:

3. Play the sound


To view the code and the whole article go to: http://silverlighttips.com/?tag=/mediaelement

Posted on Friday, December 11, 2009 5:29 PM Blogs | Back to top


Comments on this post: Play Sound in Silverlight Using MediaElement

# re: Play Sound in Silverlight Using MediaElement
Requesting Gravatar...
Nice start. Keep it going.
Left by vladl on Dec 12, 2009 12:33 AM

Your comment:
 (will show your gravatar)


Copyright © CatherineRussell | Powered by: GeeksWithBlogs.net