I am trying to add audio on load notification on chrome. My Js code below. it's working fine on firefox but sometimes on chrome it's not running m

error

Uncaught (in promise) DOMException

audio_notice = new Audio('http://www.sousound.com/music/healing/healing_01.mp3');
     audio_notice.autoplay = true;
    audio_notice.addEventListener('ended', function () {
        try {
            this.currentTime = 0;
            this.play();
        } catch (e) {
        }
    }, false);
    audio_notice.addEventListener('load', function () {
        try {
            this.play();
        } catch (e) {
        }
    }, true);

## LIve example ##

1 Answers

1
R3tep On

I think the event "load" is not correct, it's not in the list of compatible events.

You can use loadeddata instead

audio_notice.addEventListener('loadeddata', function () {
    try {
        this.play();
    } catch (e) {
    }
}, true);