Console.Beep()

D

Donar

Good day, Ladies and Gents,

what can I use au lieu of
Console.Beep()
on a Vista Ultimate 64 bit?

On a certain activity on one of my pages I want the host to emit a
beep (or just any sound, for that matter) to attract the operator's
attention. I thought of using Console.Beep(), but had to learn, that
it won't work on 64-bitters (eventhough the site under IIS7 is running
in 32-bit mode because it has to access a Access 2007 db).

Thanks in advance for sensible suggestions,
//Donar
 
J

Joe Cool

Good day, Ladies and Gents,

what can I use au lieu of
Console.Beep()
on a Vista Ultimate 64 bit?

On a certain activity on one of my pages I want the host to emit a
beep (or just any sound, for that matter) to attract the operator's
attention. I thought of using Console.Beep(), but had to learn, that
it won't work on 64-bitters (eventhough the site under IIS7 is running
in 32-bit mode because it has to access a Access 2007 db).

Thanks in advance for sensible suggestions,
//Donar

You could embed a WAV file that plays the sound you want as a project
resource and then play it with an instance of the SoundPlayer class.
 
J

Joe Cool

You could embed a WAV file that plays the sound you want as a project
resource and then play it with an instance of the SoundPlayer class.

I have already done this, here is the code I wrote:

private void Beep()
{
Assembly assembly
Stream stream;
SoundPlayer player;

assembly = System.Reflection.Assembly.GetExecutingAssembly();
stream = assembly.GetManifestResourceStream
("<yourProjectName>.beep.wav");
player = new SoundPlayer(stream);
player.Play();
}

Of course, you will need to have already embedded a file named
beep.wav as a project resource. And "yourProjectName" is case
sensitive.
 
K

KH

I'd imagine that Console.Beep just calls this, but you might try it:

System.Media.SystemSounds.Beep.Play();

HTH
 
D

Donar

On Oct 19, 12:32 pm, Joe Cool <[email protected]> wrote:
private void Beep()
{
Assembly assembly
Stream stream;
SoundPlayer player;

assembly = System.Reflection.Assembly.GetExecutingAssembly();
stream = assembly.GetManifestResourceStream
("<yourProjectName>.beep.wav");
player = new SoundPlayer(stream);
player.Play();

}

Of course, you will need to have already embedded a file named
beep.wav as a project resource. And "yourProjectName" is case
sensitive.

Unfortunately, neither of the suggestions worked.

I am not sure if I made it clear that the beep shall appear at the
host's end, not in the clients' browsers, i.e., it must be executed
when the code is executed on the server. Also, this is a Web app.

Joe, it looks like your code should run. I am compiling it without
problems, but a test call to Beep() does not beep (nor trigger an
exception). What could the cause be? I am using VWD Express: Add >
existing item > beep.wav (which is located in the projects folder)
should do the job of including the sound file as a project resource,
or am I wrong here?

Regards,
Donar
 
P

Patrice

I am not sure if I made it clear that the beep shall appear at the
host's end, not in the clients' browsers, i.e., it must be executed
when the code is executed on the server. Also, this is a Web app.

Unclear. Note sure to understand what is the purpose of having this at the
serve. Do you have someone near the server ? Is this person supposed to ear
something else each time somebody else is doing something particular on the
web site ?

Anyway if nobody is locally logged on the server, I doubt you can emit a
sound.

You may want to explain what you are trying to do (for example another
solution could be to use an instant messaging client to inform whoever needs
to be informed)
 
D

Donar

Unclear. Note sure to understand what is the purpose of having this at the
serve. Do you have someone near the server ? Is this person supposed to ear
something else each time somebody else is doing something particular on the
web site ?

Anyway if nobody is locally logged on the server, I doubt you can emit a
sound.

You may want to explain what you are trying to do (for example another
solution could be to use an instant messaging client to inform whoever needs
to be informed)

Hello Patrice, thanks for answering.

The reason? Short answer: The customer wants it so.

Long answer: The beep serves to attract the operator's attention, that
a certain page has been called, which is just one of an elaborated
ordering procedure, namely one which which is called when someone (the
operator) has to deal with problems. When called, the problem details
are already in the database. When the beep is triggered the operator
has to check the details via a GUI accessing the database and to react
appropriately to clear such problems. He also has to check after
returning from an absence. Beeps are expected to occur infrequently.

Of course there are workarounds. One could send a mail, for example,
and there surely are other even more over-engineered solutions.
However, the customer wants a Beep. And there really should be nothing
wrong with a Beep() to notify a person about a certain situation:
that's why beeps were created in the computer's infancy ;)

To answer the other question: the operator is logged on the Web server
(and additionally to a client machine next to him). His main focus is
on the client machine, though.

Anyway: I can not see why emitting a Beep must be so complicated.
Also, why isn't a Beep supported anymore with 64-bitters? Strange
things.

Best regards,
Donar
 
H

Helmut Giese

Hi Donar,
you have of course verified that the machine in question is _capable_
of producing sounds.
Best regards
Helmut Giese
 
D

Donar

Hi Donar,
you have of course verified that the machine in question is _capable_
of producing sounds.
Best regards
Helmut Giese

Yes, Helmut, of course.

I use a 12 kB small Beep.wav, which sounds perfectly right in the
Media Player. Short, concise and a bit alerting ;)

Kind regards,
Donar
 
F

Family Tree Mike

Donar said:
Yes, Helmut, of course.

I use a 12 kB small Beep.wav, which sounds perfectly right in the
Media Player. Short, concise and a bit alerting ;)

Kind regards,
Donar

Your first post seems to indicate this works on "some" machine
somewhere, but you are in doubt about Vista 64. Can you share the web
page and system where your code _does_ work? Maybe I misunderstood the
first post?
 
D

Donar

Your first post seems to indicate this works on "some" machine
somewhere, but you are in doubt about Vista 64.  Can you share the web
page and system where your code _does_ work?  Maybe I misunderstood the
first post?

Hello Mike

I am sorry if it was suggested that it worked on a 32 bit system
earlier. This is not the case here: I never had this requirement
before.

My reference was due to various discussions in the Web stating that
the beep is not supported anymore in 64 bit environments. This
naturally causes uncertainty when searching for the reasons of a not
working beep.

Regards,
Donar
 
F

Family Tree Mike

Donar said:
On Oct 20, 11:10 pm, Family Tree Mike

Hello Mike

I am sorry if it was suggested that it worked on a 32 bit system
earlier. This is not the case here: I never had this requirement
before.

My reference was due to various discussions in the Web stating that
the beep is not supported anymore in 64 bit environments. This
naturally causes uncertainty when searching for the reasons of a not
working beep.

Regards,
Donar

Donar,

I could have sworn this worked for me, but your right. No sound on my
64 bit machine. This function in User32.dll, MessageBeep(int type),
does work on 64 bit, in a console app. I would try this.

http://pinvoke.net/default.aspx/user32/MessageBeep.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top