-3

Is there any way to play 2 audio files simultaneously? I have an audio file that will be played in a loop and while this sound plays, I'm trying to play another sound. I was expecting that both of them will be played simultaneously, but it looks like both sounds are placed in a sequence, that only one sound can be played at a time

dw96
  • 35
  • 2
  • 6
  • 1
    checkout how to ask, you are missing a lot of information we need to help you out. https://stackoverflow.com/help/how-to-ask – Andrew Lohr Jan 27 '20 at 21:27
  • Possible duplicate of this question? https://stackoverflow.com/questions/11652197/play-multiple-sound-at-the-same-time – Run_Script Jan 27 '20 at 21:32

1 Answers1

1

You can use the Audio constructor

const music = new Audio('myPathTo/music.mp3')
const soundEffects = new Audio('myPathTo/effects.mp3')

and then

music.play()
soundEffects.play()
Nermin
  • 749
  • 7
  • 17