gpt4 book ai didi

asp.net - 如何在asp页面中播放/暂停wav文件

转载 作者:行者123 更新时间:2023-12-02 15:34:57 25 4
gpt4 key购买 nike

我需要在 asp.net 页面上播放和暂停 .wav 文件,但我无法使用 Flash,并且它需要成为最轻量的解决方案。我找到了如何播放声音,但找不到停止它的方法。

这是我的代码:(使用“embed”元素在 IE 中不起作用,但使用“bgsound”则在 Chrome 中不起作用)

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

<script type="text/javascript">

var soundObject = null;


function PlaySound() {

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);
}

</script>

</head>

<body>

<form id="form1" runat="server">

<input type = "button" onclick = "PlaySound()" value = "Play Sound" />

</form>

</body>

</html>

最佳答案

您可以使用此命名空间“Microsoft.DirectX.AudioVideoPlayback”来执行此操作

这里是一个例子 - http://msdn.microsoft.com/en-us/library/bb324497(VS.85).aspx

关于asp.net - 如何在asp页面中播放/暂停wav文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15909172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com