Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,


I want to play a wav file when user click on a particular button in webpage.

In local server its working fine with SoundPlayer class

The code follows :

SoundPlayer player = new SoundPlayer();
player.SoundLocation = @"http://intranet.divoli.in/Sound/alarm.wav";
player.Play();
System.Threading.Thread.Sleep(2000);
player.Stop();


But when uploading to server,the sound will not playing, i knw its not possible.

I want to solve this,want to play that sound on client browser itself, can anyone give me a solutions that will help me?



Thanks

Kishore R
Posted
Updated 28-Feb-12 22:13pm
v2
Comments
Sergey Alexandrovich Kryukov 29-Feb-12 2:46am    
(Sigh...) :-)
--SA

You can do this by embedding mediaplayer in webpage.


On Code Behind
-----------------

protected void Button1_Click(object sender, EventArgs e)
{
        try
        {
           playSound();
        }
        catch (Exception ex)
        {
            Response.Write("Error in Page:" + ex.Message);
        }
}

public void playSound()
{
  mySrc = @"http://intranet.divoli.in//Sound//alarm.wav";
}


aspx page
-----------

<asp:Panel ID="Panel1" runat="server" Height="1px" Width="1px">
            <object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="player" 
                class="style3" height="1px" width="1px" >
                <param name="url" value="<%=mySrc %>" />
                <param name="src" value="<%=mySrc %>" />
                <param name="showcontrols" value="true" />
                <param name="autostart" value="true" />
               <!--[if !IE]>-->
                    <object type="video/x-ms-wmv" data="<%=mySrc %>" class="style4" height="1px" width="1px">
                        <param name="src" value="<%=mySrc %>" />
                        <param name="autostart" value="true" />
                        <param name="controller" value="true" />
                </object>
               <!--<![endif]-->
           </object>
        </asp:Panel>





Thanks
 
Share this answer
 
v2
Wow! Well, your sound is played — on the server. And the purpose of it? If your server host had the speakers, the best you could achieve would be the neural disorder in service personnel like system administrators. :-)

Thinks about learning how Web works before doing your development. You really need it.

Good luck,
—SA
 
Share this answer
 
v2
Comments
kishore Rajendran 29-Feb-12 3:23am    
good reply,thanks
Try to understand question, or tell to explain more before posting this type of comments ,anyway thanks for your post :)

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