发布ASP.NET Web应用程序时,听不到任何声音

时间:2013-08-24 16:07:11

标签: asp.net

我在ASP.NET中有一个网站应用程序。我有两个mp3声音。一切都在计算机上工作(在localhost中)。当我发布网站时,我没有错误,但按下按钮时,没有声音。我什么都没听到。我究竟做错了什么?感谢

protected void Button1_Click(object sender, EventArgs e)
{
    var firstVoice = new System.Windows.Media.MediaPlayer();
    var secondVoice = new System.Windows.Media.MediaPlayer();


    firstVoice.Open(new System.Uri(Server.MapPath("~/") + @"\first.mp3"));

    firstVoice.Play();

    System.Threading.Thread.Sleep(1500);

    secondVoice.Open(new System.Uri(Server.MapPath("~/") + @"\second.mp3"));

    secondVoice.Play();


    secondVoice.Stop();


}

在这段代码中,我有两个声音同时播放。

2 个答案:

答案 0 :(得分:4)

如果它播放任何声音,它会在服务器上播放。不在客户端机器上。它适用于locahost,因为它既是服务器又是客户端。

答案 1 :(得分:1)

您必须实施客户端媒体播放器。只需谷歌“HTML媒体播放器”或“JavaScript媒体播放器”。

例如,此处描述了基础知识:http://www.w3schools.com/html/html_sounds.asp

有更多奇特的解决方案,例如http://jplayer.org