Reputation: 133
This error (The play() request was interrupted by a call to pause()) happen after several fast key down/up. How can I fix it?
//audio will start plying with key down
function keydown() {
if (audio.classList.contains('holding') == false) {
if (audio.src != '') {
audio.classList.add('holding');
if (audio.paused) {
audio.play();
} else {
audio.currentTime = 0;
}
}
}
}
//and audio will stop playing with key up
function keyup() {
if (audio.src != '') {
audio.pause();
audio.currentTime = 0;
}
audio.classList.remove('holding');
}
Upvotes: 0
Views: 275
Reputation: 133
This error is because of the delay that occurs while processing the audio file.
I solved this by adjusting the audio base64 size limit (for example 5MBs).
Upvotes: 0