在本地VS调试的时候下面的方法都是可以播放声音的,但是当我发布到iis,然后通过ie或者其他浏览器去访问,就没有声音了,请各位帮忙分析原因,谢谢! [DllImport("winmm.dll")]
public static extern bool PlaySound(string pszSound, int hmod, int fdwSound);
public const int SND_FILENAME = 0x00020000;
public const int SND_ASYNC = 0x0001;
//private static string m_strWAV = HttpRuntime.AppDomainAppPath + "file\\warn.wav";
private static string m_strWAV = "http://127.0.0.1/file/warn.wav";
private static string m_strWAV1 = "c:\\warn.wav";
public static System.Timers.Timer m_WarnTimer = null;
//调用
//方法一
PlaySound(m_strWAV1, 0, SND_ASYNC | SND_FILENAME);
//方法二
SoundPlayer sp1 = new System.Media.SoundPlayer(m_strWAV1);
sp1.Play();
//方法三
SoundPlayer player = new SoundPlayer(Properties.Resources.warn); //创建 player 对象
player.PlayLooping();
public static extern bool PlaySound(string pszSound, int hmod, int fdwSound);
public const int SND_FILENAME = 0x00020000;
public const int SND_ASYNC = 0x0001;
//private static string m_strWAV = HttpRuntime.AppDomainAppPath + "file\\warn.wav";
private static string m_strWAV = "http://127.0.0.1/file/warn.wav";
private static string m_strWAV1 = "c:\\warn.wav";
public static System.Timers.Timer m_WarnTimer = null;
//调用
//方法一
PlaySound(m_strWAV1, 0, SND_ASYNC | SND_FILENAME);
//方法二
SoundPlayer sp1 = new System.Media.SoundPlayer(m_strWAV1);
sp1.Play();
//方法三
SoundPlayer player = new SoundPlayer(Properties.Resources.warn); //创建 player 对象
player.PlayLooping();
当你发布到 IIS 上去后,这个 本地 就是 IIS 所在机器了
且不说 winmm.dll 能否支持运行在服务中,他播放出的声音也是在远方服务器上的,你如何能听的到?
服务端转MP3,然后用Audio标签加载
vid.play();
} function pauseVid() {
vid.pause();
}