Solved

Keypad beeping

Posted on 2011-02-15
10
411 Views
Last Modified: 2013-12-17
Hi,

During download file, I'd like the keypad beeping by writing C#
program. But I don't know how, could you give me a hand?
Thanks,
JT
0
Comment
Question by:jtran007
10 Comments
 
LVL 9

Expert Comment

by:s_chilkury
ID: 34903720
Playing Beep :

public void playBeep()
{
    SystemSounds.Exclamation.Play();
}

Playing custom sound:

private void playCustomSound()
{
    SoundPlayer simpleSound = new SoundPlayer(@"c:\Windows\Media\chimes.wav");
    simpleSound.Play();
}
0
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 34903756
You may need to add name spaces like System.Media.

You can utilize the namespace and its SystemSound and SystemSounds classes (http://msdn.microsoft.com/en-us/library/system.media.systemsound.aspx)

The SystemSounds class contains five static properties that you can use to retrieve instances of the SystemSound class. This class in turn contains the Play() method, which you can use to play the wave file associated with the sound in Windows Control Panel. Note that the user can also disable all sounds altogether, which would mean that no sound can be heard through the computer speakers.

To play for example the classical beep sound, you could use the following code:

System.Media.SystemSounds.Beep.Play();
Similarly, you could play the “Question” sound with this code:

System.Media.SystemSounds.Question.Play();
The System.Media namespace is defined in System.dll, so there are no new DLLs you would need to add to your project’s references to use the above code.
0
 
LVL 29

Expert Comment

by:anarki_jimbel
ID: 34903786
0
 

Author Comment

by:jtran007
ID: 34903875
Hi,

Thanks, but how can I play it continuously until my file download is completed.

Regards,
JT
0
 
LVL 11

Assisted Solution

by:SAMIR BHOGAYTA
SAMIR BHOGAYTA earned 100 total points
ID: 34904534
Hi, use this code

//First add reference 'Microsoft.VisualBasic.DLL' to the project.
//then include
using Microsoft.VisualBasic.Devices;
//Now

Audio myAudio = new Audio();

myAudio.Play(@"d:\abc.wav");
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 100 total points
ID: 34908679
>>  Thanks, but how can I play it continuously until my file download is completed.

You're going to have to spawn a separate thread. You might want to take a look at BackgroundWorker (http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) or ThreadPool (http://msdn.microsoft.com/en-us/library/system.threading.threadpool.aspx).
0
 
LVL 29

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 50 total points
ID: 34913329
I'd use wav player (see reference above), use PlayLooping mode, detect when dowloading completes (it depends, I don't know how you download - just handle events, I believe), then call player.stop:

http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx

0
 

Accepted Solution

by:
jtran007 earned 0 total points
ID: 34914519
Hi ,

Since I have a background thread handling download file, and I prefer the playing sound thread
not interferering with the background process. So which approach is the best way.

Thanks for your input.
JT
0
 

Author Comment

by:jtran007
ID: 34940290
Hi,

Sorry I still don't know how to stop the sound even at the end of uploading file, I stop the
background task where I play sound in the loop. But the sound keeps playing. Please help.

Thanks,
JT
0
 

Author Closing Comment

by:jtran007
ID: 34968331
Thanks,
JT
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

759 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

21 Experts available now in Live!

Get 1:1 Help Now