Wednesday, March 28, 2012

System.Media.SystemSounds not playing

The title is only half true, which is the thing that confuses me.

In my code behind, I am calling

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

whenever there is an incorrect input from the user. This works perfectly when I run it locally on my machine, but when I upload it to the server and run it from the website, the page works exactly the same except that there is no sound played. I've tried this with System.Media.SoundPlayer as well to the same effect. I'm doing the tests from the same computer. I've also remoted into the server and tried it there with no sound playing. The server is Windows Server 2003, running the project in Framework 2.0.

Does anyone know why this is a problem?

it's playing - on the server

as you said - you have it in the code-behind, which is executed on the server.

You would need something client-side to play through client browser.

Not sure how to do that


Aha, that's the problem. Thanks for that!

Just to test it, I ran IIS off of my computer and let some people make my computer ding repeatedly. I believe they enjoyed it far too much. I just tried embedding the Play() method in the .aspx file, but that doesn't work either.

I'm thinking I'll have to do some client-side scripting of some javascript in there. Something like

<%

if (bError)

{

%>

_javascript_

<%

}

I don't know a way to make a sound without a dialog box, however. I'll do some searching.


if you find the solution - post so others may benefit

mark the post as answered please....

0 comments:

Post a Comment