How to autoplay audio in Chrome (Angular)?

Viewed 478

I have to implement a sound notification and I just can't get audio to play on Chrome if the user hasn't interacted with the page.

I have tried workarounds like:

  • adding iframe with a dummy audio file,
  • using ViewChild with the play() method,
  • even using a click() on a button and then trying to play() method again.

None of these seem to work. The only result I had was when the user interacted with the page, but if he refreshes the page and doesn't interact with the page, no sound will play which beats the purpose of the audio notification.

Autoplay seems to not have any problems with Edge, anyone know a good workaround for Chrome?

Stackblitz exemple of my implementation is here

1 Answers
Related