jeudi 12 mars 2015

How can I allow background music to continue playing while my app still plays its sounds while using Swift


Vote count:

0




I created an app and I am attempting to allow the user to continue to listen to their music while playing my game, but whenever they hit "play" and the ingame sounds occur it will stop the background music. I am developing on iOS using Swift. Here is a piece of the code that initiates the ingame sounds.


func playSpawnedDot() { var alertSound: NSURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("spawnDot", ofType: "mp3")!)! var error:NSError? audioPlayer = AVAudioPlayer(contentsOfURL: alertSound, error: &error) audioPlayer.prepareToPlay()



if volumeBool {
audioPlayer.play()
}


}



asked 21 secs ago







How can I allow background music to continue playing while my app still plays its sounds while using Swift

Aucun commentaire:

Enregistrer un commentaire