在网站按钮中播放声音请点击
问题描述:
当用户单击网页中的特定按钮时,我想播放wav文件.
在本地服务器中,它可以与SoundPlayer类一起正常工作
代码如下:
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();
但是当上传到服务器时,声音将不会播放,我无法知道.
我想解决这个问题,想在客户端浏览器上播放声音,谁能给我一个可以帮助我的解决方案?
谢谢
Kishore R
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
答
您可以通过将mediaplayer嵌入网页来实现.
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
哇!好吧,您的声音已在服务器上播放.目的是什么?如果您的服务器主机上有扬声器,那么您可以实现的最佳效果就是服务人员(如系统管理员)的神经疾病. :-)
考虑在进行开发之前先了解Web的工作原理.您真的需要它.
祝你好运,—SA
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