Welcome to WindowsClient.net | My Blog | Sign in | Join

Windows Client Videos

How Do I: Add Sound to a WPF Application

A WPF application is not only about visual appeal. To complete the application experience, it is often desirable for audible effects to accompany application events. In this video, Todd Miranda shows how to add sound to a WPF application using the SoundPlayer.

By: Todd Miranda

Posted: Jul 24 2008, 04:50 AM by jytylr | with 6 comment(s)
Filed under:

Comments

klickmann said:

Nice tuorial but it should be named how to create big buttons. I think to show how i can play sound it was enough to use a couple of standard buttons and loose so much time to do something different. After this its a good tutorial.

# July 28, 2008 5:39 PM

tmiranda said:

Actually, I was going to animate the buttons and make them spin while the sound played but figured I would just stick with big buttons! :)  All kidding aside, I appreciate the feedback.

Thanks,

Todd

# August 7, 2008 1:45 AM

marklitt said:

The soundplayer is very basic and I would have prefered instructions on how to connect up a mediaplayer. I've tried to do it in blend which works fine in the timeline but when I attach it to a load window event I get no sound. Well when I created a new basic project and added it, all worked fine. Really don't understand what is wrong

# August 19, 2008 3:58 PM

tmiranda said:

marklitt,

  I have done a video using MediaPlayer and MediaTimeline as well.  It should be posted soon...  Without looking at the code, not sure what could be the problem with the sound on window load.  There may be another event handler that is interfering somewhere.

Todd

# August 22, 2008 8:36 AM

TacoBallZ said:

I'm trying to find the best way to drive an audio tone through the soundcard of my computer and drive the pitch with a slider bar. Can soundplayer be manipulated to do something like this? or is there another method for FM midi that I need to use? by the way, thanks for the great videos!

-Mark W.

# August 25, 2008 4:28 PM

luisbragagnolo@hotmail.com said:

Hi, Thanks for that video, but i have a BIG problem, How can I bind a "Sileder" and use it as Volume control? in WPF is really easy but didn't work in Silverlight.

This is in WPF:

        <MediaElement Name="VideoFile" Width="200" Height="180"

                     Source="Hillsong.wmv" />

       <Slider Name="ElVolumen" Minimum="0" Maximum="1" Width="200"

              <Value="{Binding ElementName=VideoFile, Path=Volume}"/>

Can I do that in C#? or in xaml? how!!!!????? thanks a lot for your help.

:o)

# October 25, 2008 11:40 PM