Adding a sound to the Button Click via PlaySoundAction in Windows Phone 7

Sometimes it may be necessary for you to play a sound on some action in your Windows Phone 7 . This could be on click of the button for the user to feel that he has touched something or may be someother scenario .

You can do this easily with the help of Microsoft Expression Blend 4 with the behavious known as PlaySoundAction .

To include a sound on the button click , follow the below steps .

1. Start the Expression Blend 4 and the open the current Project .

2. Add a button to the Page from the Assets tab – Controls

3. Change the Button properties like the name of the button or the text to be displayed on the button .

4. From the same assets tab – > Behaviours – select the PlaySoundAction – Drag and drop onto the button .

5. In the Objects and Timeline , make sure that you select the PlaySoundAction and now go  to the properties window on the right side of the screen .

6. Select the Event for which this behaviour should trigger . In our case it is the Click Event . Also select the Source file ( Media File) to play and the Volume .
7. Save all the change and press F5 to start the Application . When you click the button , you should be able to listen to the sound .

Here’s a video that demonstrates how to use PlaySoundAction in ExpressionBlend .

Using PlaySound Action for Button in Expresssion Blend

 

References

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

9 Responses

  1. Pingback: Adding a sound to the Button Click via PlaySoundAction in Windows Phone 7 | ProgramInDotnet
  2. Hi, great Tutorial but i would like to know how to make a button that stops the sound playing

    Can someone PLEASE tell me how to do that

  3. haii… nice work dude…. bw i have a doubt.. does it fits in a normal wp7 project ??? i guess we have to use xna frame work to start and stop play….
    can u tell me.. what project did u choose and what was its corresponding coding

Leave a Reply