Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
1.57/5 (5 votes)
See more:
I have a website application in ASP.NET. I haveone wave sounds. Everything works in the computer(in localhost). When I publish the website, I have no error but when press the button, there is no sound. I don't hear anything. What am I doing wrong? Thanks
C#
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation =Server.MapPath("~/Sounds/Incoming_Message.wav");
player.Play();
Posted
Comments
[no name] 26-Aug-13 9:49am    
Is it possible that the sound is being played on the server and you are not hearing it when trying to listen on the client side?
Mahesh_Bhosale 26-Aug-13 9:59am    
ya its true.
it plays it on server. Not on client machine. It worked on locahost because it is both server and client.

but how to play on client side..?
Joezer BH 26-Aug-13 10:01am    
See posted solution below :)
Herbisaurus 26-Aug-13 9:59am    
Show some more code, where it runs, what your intention is etc

It looks like you used C# which will play sound on the server side.

To play sound on the client side (typically a Web Browser), you can use HTML (and especially HTML5), Javascript:
Playing Sounds in HTML - W3Schools[^]
or Play sound with javascript[^]
In flash: Using sounds in Flash[^]

Cheers,
Edo
 
Share this answer
 
v3
Comments
Thomas Daniels 26-Aug-13 10:08am    
+5!
Well, the sound is being played on the server and not on the client machine. That's why you can't hear it :) So, to play sound on the client machine, you need to embed the sound using HTML <embed /> tag like <embed src="sound.wav" />. You can find details of the embed tag over the internet.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900