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

billrobin 2013-05-30 06:34:35
如何播放wav文件和停止播放wav文件呢?
...全文
233 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
宝_爸 2013-05-30
  • 打赏
  • 举报
回复
它建议私用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
宝_爸 2013-05-30
  • 打赏
  • 举报
回复
好像只有IE支持,w3cshcool上不推荐使用 http://www.w3.org/wiki/HTML/Elements/bgsound Examples No, really. Don't use it.
Cee 2013-05-30
  • 打赏
  • 举报
回复
引用 3 楼 findcaiyzh 的回复:


        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
看明白大概,setAttribute查了才知道大意,这对我很有用,谢谢啦
宝_爸 2013-05-30
  • 打赏
  • 举报
回复


        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
宝_爸 2013-05-30
  • 打赏
  • 举报
回复
asp.net?
Cee 2013-05-30
  • 打赏
  • 举报
回复
我也不太清除,才学一周,vs2010下我刚才试了下把wav文件直接拖到代码上,结果是超链接的样子,而且一点还是下载,陪你坐等高手。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧