2

Let's say I have two audio files. I hooked them up with my javascript.

var audio1 = new Audio();
audio1.src = 'file1';
audio1.load();

var audio2 = new Audio();
audio2.src = 'file2';
audio2.load();

when I play audio1 then play audio2, mobile safari (ios) stops audio1 then plays audio2. It only happens with ios safari.

Moon
  • 22,195
  • 68
  • 188
  • 269

3 Answers3

3

As far as I'm aware, this is a design decision from Apple, it'S not possible to play more than one audio file.

Ian Devlin
  • 18,534
  • 6
  • 55
  • 73
  • crazy , i just use this : http://stackoverflow.com/questions/5194898/html5-audio-multiple-play/35459153#35459153 I can play as much as I want audio files. I just check now , background music works with click sounds on iOS mini ipad. – Nikola Lukic Feb 17 '16 at 14:24
1

I did some testing on this recently. The short answer is as stated before, it doesn't work. I tried working with mp3,m4a(aac I purchased on itunes),mp4 and aif, so file format has no bearing on iOS safari's ability to play more than one stream at a time.

I have currently "solved" the issue in my web app by assigning priorities to sounds in the app so it can intelligently interrupt or ignore requests to play a sound file. Maybe you can try something similar.

Rob Lynch
  • 591
  • 4
  • 11
0

One possible workaround is to use server-side utility like sox to mix multiple audio files into one. It is not equivalent to playing multiple audio files at random position but depending on your needs it can be a solution.