I am trying to play a sound but my current code bases the volume off of the ringtone volume. How to I change this to media volume?
var player: AVAudioPlayer?
...
func playSound(name: String) {
let url = Bundle.main.url(forResource: name, withExtension: "mp3")!
do {
player = try AVAudioPlayer(contentsOf: url)
guard let player = player else {return}
player.prepareToPlay()
player.play()
}catch let error {
print(error.localizedDescription)
}
}
...
playSound(name: "baby")