I am using the following function to play sound fx in my app. I want to make it so the user can be listening to their iphone music at the same time.
I am using this on multiple view controllers also.. not sure if that will change anything. What is the easiest way to accomplish this?
var audioPlayer = AVAudioPlayer()
func playSound (Sound: String, Type: String) {
let path = NSBundle.mainBundle().pathForResource(Sound, ofType: Type)!
let url = NSURL(fileURLWithPath: path)
do {
let sound = try AVAudioPlayer(contentsOfURL: url)
audioPlayer = sound
sound.play()
} catch {
// couldn't load file :(
}
}