gpt4 book ai didi

jquery - 如何使用 jQuery 播放 wav 音频文件?为什么wav文件无法解码?

转载 作者:行者123 更新时间:2023-12-01 08:07:04 25 4
gpt4 key购买 nike

我试图在按下“提交”按钮时播放一个 wav 文件。由于某种原因,我不断看到此错误:
媒体资源文件:///Users/Bryan/webapp/buzzer.wav无法解码。

我做错了什么?

<!DOCTYPE html>   
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
</head>

<body>

<audio id="buzzer" src="buzzer.wav" type="audio/wav">Your browser does not support the &#60;audio&#62; element.</audio>
<form id='sample' action="#" data-ajax="false">
<fieldset>
<input value="Start" type="submit">
</fieldset>
</form>
<script type="text/javascript">

var buzzer = $('buzzer')[0];

$(document).on('submit', '#sample', function() {
alert("submitted");
buzzer.play();
return false;
});

</script>
</body>
</html>

最佳答案

听起来问题出在您的 wav 文件上,也可能出在您所在的特定浏览器上。

请参阅此相关帖子:Firefox won't play .WAV files using the HTML5 <audio> tag?

关于jquery - 如何使用 jQuery 播放 wav 音频文件?为什么wav文件无法解码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15838544/

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