Reputation: 875
I have added sounds to my game using AVFoundation and it works perfectly, except that in both setting mute ON and OFF (using physical mute button of the iPhone) the sounds play. How can I make my app to mute the sounds when the Mute Button is ON? this is the code I am using:
import AVFoundation
var audioPlayerMenu = AVAudioPlayer()
var selectSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("select", ofType: "mp3")!)
audioPlayerMenu = AVAudioPlayer(contentsOfURL: selectSound, error: nil)
audioPlayerMenu.prepareToPlay()
audioPlayerMenu.play()
Upvotes: 2
Views: 614
Reputation: 101
You can't do that using AVFoundation, I suggest allowing the user to choose inside your application to mute the sounds. Thats how almost every app I;ve seen they do it
Upvotes: 2