Created
May 26, 2020 18:27
-
-
Save bob910078/c1c55651cab887493ed13164782252de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isHeadphonePluggedIn: Bool { | |
let audioOutputs: [AVAudioSessionPortDescription] = AVAudioSession.sharedInstance().currentRoute.outputs | |
for output in audioOutputs where output.portType == AVAudioSessionPortHeadphones { | |
print("headphone plugged in") | |
return true | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment