Skip to content

Instantly share code, notes, and snippets.

@tsraveling
Created May 11, 2017 18:25
Show Gist options
  • Save tsraveling/ac0c9a2be6daceb05d0a05c2404fc39b to your computer and use it in GitHub Desktop.
Save tsraveling/ac0c9a2be6daceb05d0a05c2404fc39b to your computer and use it in GitHub Desktop.
Play sound through speakers
// Play sound through speakers
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)
} catch _ {
}
do {
try AVAudioSession.sharedInstance().setActive(true)
} catch _ {
}
do {
try AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.speaker)
} catch _ {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment