如何播放wav文件和停止播放wav文件呢?wav

解决方案 »

  1.   

    我也不太清除,才学一周,vs2010下我刚才试了下把wav文件直接拖到代码上,结果是超链接的样子,而且一点还是下载,陪你坐等高手。
      

  2.   


            if (soundObject != null) {                document.body.removeChild(soundObject);
                    soundObject = null;            }            soundObject = document.createElement("bgsound");            soundObject.setAttribute("src", "C:/sound1.wav");            soundObject.setAttribute("hidden", true);            soundObject.setAttribute("autostart", true);            document.body.appendChild(soundObject);
            }   function StopSound()
            {
                 if (soundObject != null) {                soundObject.setAttribute("src", "");
                    soundObject = null;            }
            }    </script></head><body>    <form id="form1" runat="server">        <input type = "button" onclick = "PlaySound()" value = "Play Sound" />    </form></body></html>
    代码来自:
    http://stackoverflow.com/questions/15909172/how-to-play-pause-a-wav-file-in-asp-page
      

  3.   

    看明白大概,setAttribute查了才知道大意,这对我很有用,谢谢啦
      

  4.   

    好像只有IE支持,w3cshcool上不推荐使用http://www.w3.org/wiki/HTML/Elements/bgsoundExamples
    No, really. Don't use it.
      

  5.   

    它建议私用html5的 Audio 标签Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support the <audio> element.<audio controls>
      <source src="horse.ogg" type="audio/ogg">
      <source src="horse.mp3" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>参考:
    http://www.w3schools.com/html/html5_audio.asp