Solved

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

Posted on 2007-11-17
3
223 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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