Question

I create this web application that provides sound whenever the number in the window changes. When I run my application in Visual Studio, The sound perfectly works but when I open my web with IIS 7, the sound doesn't work anymore.

What causes this? And How can I solve it?

I'm using ASP.Net by the way.

thanks for immediate response.

This is the code that i use

public void providesound()

{

 System.Reflection.Assembly a =System.Reflection.Assembly.GetExecutingAssembly();
 System.IO.Stream s = a.GetManifestResourceStream("~/sound/beep.wav");
 SoundPlayer player = new SoundPlayer(s);
 player.Play(); 

}
Was it helpful?

Solution 2

I'm able to accomplish this task by creating a Javascript

 function EvalSound(soundobj)
 {
         var thissound = document.getElementById(soundobj);
         thissound.play();
 }
 <audio id="audio1" src="Sound/beep.wav" controls preload="auto" autobuffer HIDDEN=true >

and in my .cs

 public void CreateSound()
 {

        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append(@"<script language='javascript'>");
        sb.Append(@"EvalSound('audio1');");
        sb.Append(@"</script>");
        System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(),     "JCall1", sb.ToString(), false);

 }

You can add the CreateSound() in Button_Click.

OTHER TIPS

Since the sound is playing in your dev environment the only reason I can think of for sound not playing when deployed in IIS is that; your IIS is not configured to send the sound file across to the client. In simple words if you have a sound file say with .wav extenstion, in IIS under MIME Types of you website see if you have an entry for this extension. If not the following link can help you create the MIME entry:

http://technet.microsoft.com/en-us/library/cc725608(v=ws.10).aspx

I believe this would solve your problem, but if not then you should post the code as asked by Damien and also add the details about how you are publishing your site (step by step).

Edit 1:

Looking at the code that you are using I dont think you can make the sound work that way on your client. here are two link refer them: asp.net SoundPlayer not playing from server , How to run a .wav in client. ASP.NET

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top