Solved

Keypad beeping

Posted on 2011-02-15
10
418 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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
 
LVL 75

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

776 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