Solved

How can I play a small sound file when showing a form?

Posted on 2007-11-17
3
219 Views
Last Modified: 2013-12-17
Hi,

I want to play a sound file when showing a form. The sound file contains a little ring just to notify the user about a new messages.

What would be the most efficient way to play the file?

Please advise.
0
Comment
Question by:EEssam
  • 2
3 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20305622
have a look to this little tutorial:
http://msdn2.microsoft.com/en-us/library/4y171b18(VS.80).aspx

you will need the namespace System.Media
0
 

Author Comment

by:EEssam
ID: 20305660
This is more suitable for me:

http://msdn2.microsoft.com/en-us/library/3w5b27z4(VS.80).aspx

But how can I add the sound file as a resource?
private void playSoundFromResource()

{

    SoundPlayer sndPing = new SoundPlayer(SoundRes.GetType(), "Ping.wav");

    sndPing.Play();

}

Open in new window

0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20305693
it is a little difficult in .net
First you have to create a .res file (Win32 resource file)
Insert the sound file there, it has to be "WAV" type
Go to your project settings, Application tab, and set your resource file.

To create and edit the .res file, you can create a Native Resource Template in your VS New File Wizard, add the wav file and save as a .res file
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now