I was working with web audio API and I was following the code from https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/suspend to resume and suspend audio context. The suspending part is working but I can't resume after suspension.
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';
});
}