Search code examples
javascriptiosangularionic-frameworkcapacitor

ionic capacitor IOS: play audio in the background without stopping previously playing audio from other apps


In my angular ionic capacitor app, on IOS when I play Spotify-Music in the background and then my quiz-app makes a sound, then the spotify music will stop playing.

this is happening with both:

HTMLAudioElement https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement

and capacitor-community/native-audio (source: https://github.com/capacitor-community/native-audio/issues/40)

Does anyone have a fix to make this work?

Note: it works in android


Solution

  • I have just solved this issue myself by using this package: https://github.com/Cap-go/native-audio

    This fork is ahead of the package you have mentioned and is able to mix audio. Check out the fade and focus options mentioned in the readme.