in Chrome 65.0.3325.181 (official version) (64-bit), the loop attribute of the audio tag does not take effect. Write the corresponding logic and report an error after execution.
the code is as follows:
//html
<audio id="backgroundAudio" src="./resource/sound/bgMusic.mp3" autoplay loop/>
//js
var audio = $("-sharpbackgroundAudio")[0];
audio.addEventListener("timeupdate",()=>{
if(audio.paused){
return;
}
if(audio.currentTime >= audio.duration - 1){
audio.currentTime = 0;
const p = audio.play();
//
// if (p && (typeof Promise !== "undefined") && (p instanceof Promise)) {
// p.catch(e => log(e));
// }
}
});
the error message is as follows:
Uncaught (in promise) DOMException: The play () request was interrupted by a call to pause ().
I want to know why this error occurs, why it executes correctly after adding comment code, and why the loop property does not take effect.
Theloop attribute is due to a problem with the audio file, which has been resolved