My app is currently playing sounds based on ringer volume. It is annoying to many users seeing its a soundboard app. I've noticed that when an ad pops up featuring a video, the volume control then changes to system volume after closing the ad and resuming use of the app. With this in mind I was hoping to use a dummy(silent) sound played via AVAudioPlayer upon launch of the app, somewhat tricking it into using the system sound controller rather than ringer. Here is my current code im using to play sounds:
func playSound(fNameOnly : String, sFileExt : String = "mp3"){
let soundUrl = NSBundle.mainBundle().URLForResource(fNameOnly, withExtension: sFileExt)
var SSID : SystemSoundID = 0
if gSoundsOn && soundUrl != nil {
AudioServicesCreateSystemSoundID(soundUrl!, &SSID)
AudioServicesPlaySystemSoundWithCompletion(SSID){
AudioServicesDisposeSystemSoundID(SSID)
self.soundComplete(SSID)
}
self.soundArray.append(SSID)
}
}
I was hoping someone could help me with creating a func/method to play the dummy sound clip via AVAudioPlayer upon launch/opening of the app.