Obtén AVAudioPlayer para reproducir múltiples sonidos a la vez
Estoy tratando de reproducir varios archivos de sonido en una instancia de AVAudioPlayer, sin embargo, cuando se reproduce un sonido, el otro se detiene. No puedo reproducir más de un sonido a la vez. Aquí está mi código:
import AVFoundation
class GSAudio{
static var instance: GSAudio!
var soundFileNameURL: NSURL = NSURL()
var soundFileName = ""
var soundPlay = AVAudioPlayer()
func playSound (soundFile: String){
GSAudio.instance = self
soundFileName = soundFile
soundFileNameURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(soundFileName, ofType: "aif", inDirectory:"Sounds")!)
do{
try soundPlay = AVAudioPlayer(contentsOfURL: soundFileNameURL)
} catch {
print("Could not play sound file!")
}
soundPlay.prepareToPlay()
soundPlay.play ()
}
}
¿Alguien puede ayudarme diciéndome cómo hacer que se reproduzca más de un archivo de sonido a la vez? Cualquier ayuda es muy apreciada.
Muchas gracias kai