如何为我的音频创建暂停功能?我已在下面的脚本中使用了播放功能。暂停网络音频API声音播放
function loadSound(url) {
var request = new XMLHttpRequest();
request.open('GET', url, true);
request.responseType = 'arraybuffer';
// When loaded decode the data
request.onload = function() {
// decode the data
context.decodeAudioData(request.response, function(buffer) {
// when the audio is decoded play the sound
playSound(buffer);
}, onError);
}
request.send();
}
function playSound(buffer) {
sourceNode.buffer = buffer;
sourceNode.noteOn(0);
}
但我怎样才能暂停或停止呢?
'sourceNode.noteOff(0);' – idbehold