Play a sound on a web page without user interaction in Electron Application

Viewed 474

We have a WebRTC application that allows users to do video calls. The application opens up a new BrowserWindow when we get a notification that another user is calling them and it plays a ringtone like on a phone. The problem is that the user hasn't interacted with the new BrowserWindow yet but we want to play the ringtone. How do I ensure that Chrome's new autoplay policy doesn't block the audio play?

1 Answers

Apologies for not answering this sooner.

We ended up using the postMessage API to communicate between the parent window and child window. The Child window can communicate to the parent window when to play and sound and when to stop, this was possible because the parent window was already in focus and it could be allowed to play sounds. We also added a timeout to the ringtone.

Related