我正在使用网络音频 API,我正在遵循 https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/suspend中的代码 来恢复和暂停音频上下文。暂停部分正在工作,但暂停后我无法恢复。
window.AudioContext = window.AudioContext || window.webkitAudioContext;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia;
window.URL = window.URL || window.webkitURL;
// Store the instance of AudioContext globally
audio_context = new AudioContext;
if(audio_context.state === 'running') {
audio_context.suspend();
} else if(audio_context.state === 'suspended') {
alert("Resumed");
//audio_context.resume();
audio_context.resume().then(function() {
// susresBtn.textContent = 'Suspend context';
});
}