.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> WPF >> Post New Question Subscribe to Interview Questions

How to use SoundPlayer to play a sound in WPF?

Posted By :Syed Shakeer Hussain     Posted Date :October 26, 2010    Points :10   Category :WPF 
The following code shows how to use SoundPlayer to play
a sound:

SoundPlayer player = new SoundPlayer("tada.wav");


You can also find related Interview Question to How to use SoundPlayer to play a sound in WPF?  below: 

Which namespace provide classes to work with images, sound, video, etc?

The System.Windows.Media namespace provide classes to work with images, sound, video, etc in WPF. (More...)

You are designing a single person shooter game application. The player can choose between multiple guns.
1) Pistol with 5 bullets
2) Shotgun with 100 bullets
3) Grenade Launcher with 20 grenades

Each gun will have different sound effects and graphics.

Pressing Ctrl+Space should rotate between guns.
Which design pattern should you employ for this?

Use Strategy Pattern.

Explanation: Each gun having different performance and graphics.
So this can be accomodated in the algorithm.

Strategy pattern is best suited for shifting the guns/algorithms

There will be a IGun interface implemented by 3 classes
Pistol : IGun
Shotgun : IGun
GrenadeLauncher : IGun (More...)

How to use MediaPlayer to play an audio file in WPF?

MediaPlayer player = new MediaPlayer();

player.Open(new Uri("music.wma", UriKind.Relative));

player.Play(); (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend