I'm using AVAudio to play a sound, but when I do so, the music (In the music app) stops.
var audioPlayer: AVAudioPlayer?
func playSound(sound: String, type: String) {
if let path = Bundle.main.path(forResource: sound, ofType: type) {
do {
audioPlayer = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path))
audioPlayer?.play()
} catch {
print("ERROR")
}
}
}
// Some code here
playSound(sound: "resume", type: "m4a")
I want to make the sound act like a notification soud and that the music keeps playing. Any way to do this?