我试图在按下提交按钮时播放一个 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 <audio> 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>