我无法在任何地方找到这个问题的明确答案.我正在寻找最简单的方法来自动循环.wav文件自动在chrome中的文档加载.似乎webaudio api是最好的做法,但我找不到简单的文档.对safari和其他人的支持也会很棒但不那么重要.
我查看了w3.org示例,但没有帮助
我认为除了按钮的on.click之外,这是我最想要的:https://forestmist.org/blog/web-audio-api-loops/
在这里我为我自己的音频实现了forestmist,它在safari中完美运行但在chrome中停止:http://infinitelimitations.us/mess-motion/web-audio-api-loops-demo/index.html
这是该页面的源代码:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Audio API Loops Demo</title>
</head>
<body>
<form>
<button id="button-loop-1" type="button" value="1">Loop 1</button>
</form>
<script>
//--------------
// Audio Object
//--------------
var audio = {
buffer: {},
compatibility: {},
files: [
'hoodie_robot_clipped.wav',
'beat.wav'
],
proceed: true,
source_loop: {},
};
//-----------------
// Audio Functions
//-----------------
audio.findSync = function(n) {
var first = 0,
current = 0,
offset = 0;
// Find the audio source …Run Code Online (Sandbox Code Playgroud)