Play two audio files simultaneously in Safari

In Javascript, I have come across a situation where I need to play two audios simultaneously. One audio is the Voice script whereas other one is the Background sound(playing in loop). I've used the following code to achieve this.


var audio = new Audio();
audio.src = "voice.mp3";
audio.type = "audio/mp3";
audio.play();


var bg_audio = new Audio();
bg_audio.src = "background.mp3";
bg_audio.type = "audio/mp3";
bg_audio.loop = true;
bg_audio.play();


However, this is creating an issue In iOS Control Center (Lock Screen). Because sometimes it shows progress bar of voice player and sometimes it shows the controls for background player. I want to show controls for voice player only. Is there any workaround?


Thanks!

Replies

Is it even allowed by Apple to play two html5 audio files simultaneously?