我创建了这个Web应用程序,每当窗口中的数字更改时,该应用程序就会发出声音。当我在Visual Studio中运行我的应用程序时,声音可以正常工作,但是当我使用IIS 7打开网站时,声音不再起作用。
是什么原因造成的?我该如何解决呢?
我正在使用ASP.Net。
感谢您的即时回应。
这是我使用的代码
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();
}
我可以通过创建Javascript来完成此任务
function EvalSound(soundobj)
{
var thissound = document.getElementById(soundobj);
thissound.play();
}
<audio id="audio1" src="Sound/beep.wav" controls preload="auto" autobuffer HIDDEN=true >
在我的.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);
}
您可以在Button_Click中添加CreateSound()。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句