在本地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(); 

解决方案 »

  1.   

    播放器是在本地运行的
    当你发布到 IIS 上去后,这个 本地 就是 IIS 所在机器了
    且不说 winmm.dll 能否支持运行在服务中,他播放出的声音也是在远方服务器上的,你如何能听的到?
      

  2.   

    在服务端放了,没问题。
    服务端转MP3,然后用Audio标签加载
      

  3.   

    你这代码 只能在服务器上浏览的时候播放...无法在客户端浏览器播放的..正常是使用html标签播放第三方音频...而不是使用后台.
      

  4.   

    我通过前台<audio>实现了声音播放,但这个页面使用了母版是无刷新的,只通过JS实时加载div内数据,JS加载数据时已经打开了声音播放,但前台的audio需要重新加载整个页面才能开关声音,如F5刷新效果,声音就可以播放了,如何实现刷新呢? 测试了indow.reload();无法刷新
      

  5.   

    audio标签可以使用play和pause方法来开始及停止播放:var vid = document.getElementById("myVideo"); function playVid() { 
        vid.play(); 
    } function pauseVid() { 
        vid.pause(); 
    }
      

  6.   

    先谢谢各位,我试过了,在前台控制是可以,但我的<audio>放在用户控件中了,该用户控件包含在母版页中,有两个页面是用了此母版页,而当前刷新的区域关系到<audio>的打开和停止,此区域没有包括用户控件中的<audio>,如何控制呢?