?
Solved

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

Posted on 2007-11-17
3
Medium Priority
?
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 2000 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

Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

777 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