Uncaught (in Promise) Domexception when trying to play sound at the angle

Asked

Viewed 68 times

0

I’m trying to play a sound at the angle, but I’m getting two errors.

The first:

Uncaught (in Promise) Domexception push.. /src/app/Components/home/home.component.ts.HomeComponent.informaNovaNotificacao

The second:

GET http://localhost:4200/.. %2F.. %2F.. %2Fassets%2Fsom_notification.mp3 net::ERR_ABORTED 404 (Not Found)

I tried to:

informaNovaNotificacao(estado: boolean){
    this.novaNotificacao = estado;
    let audio = new Audio();
    audio.src = encodeURIComponent("../../../assets/som_notificacao.mp3");
    audio.load();
    audio.play();
}

If I remove the encodeURIComponent I get only the first Domexception error, but my sound does not play.

  • With the second error the audio is executed ?

  • @Victorhenrique

  • The second is a request error. It seems to me that you are making a request for the string you passed.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.