My case is simple: I need to play a warning signal and want to make sure the user will hear it, so I want to check the system volume.
How can I find out what the cur
Swift 3.1
let audioSession = AVAudioSession.sharedInstance()
var volume: Float?
do {
try audioSession.setActive(true)
volume = audioSession.outputVolume
} catch {
print("Error Setting Up Audio Session")
}
audioSession.setActive(true)
- important
For Swift 2:
let volume = AVAudioSession.sharedInstance().outputVolume
print("Output volume: \(volume)")