问题
I have made the simplest test in order to check if SoundPlayer will play a wave file. From the local machine works just fine, once the site is on IIS it doesn't play the sounds (or give any error).
Here is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Media;
public partial class Default2 : System.Web.UI.Page
{ public SoundPlayer spWave;
protected void Page_Load(object sender, EventArgs e)
{
spWave = new SoundPlayer("\\\\server\\site\\wavetest.wav");
spWave.Play();
}
}
Is there anything else I need to add to the .aspx file to get this to work?
Or is there an easier way of playing very short wave files, without displaying any media controls on the page?
回答1:
SoundPlayer is not an aspx control, you should find a web control which can play your wav file and put that on your aspx page. Now you play the wav on your web server in iis every time your page loads.
You can start here looking for playing wav files on a webpage: google: wav aspx
来源:https://stackoverflow.com/questions/15613049/asp-net-soundplayer-not-playing-from-server