[英]How to play Audio when iOS device connected to Airpods swift ios
`let session = AVAudioSession.sharedInstance() `让 session = AVAudioSession.sharedInstance()
do {
// audio session setup
try session.setCategory(AVAudioSession.Category.playback, options: [.allowAirPlay,.allowBluetoothA2DP])
try session.overrideOutputAudioPort(.none)
try session.setActive(true)
}
catch {
print(error)
}
Try to integrate this snippet, it worked to me:尝试整合这个片段,它对我有用:
[AVAudioSessionCategoryOptions.defaultToSpeaker, .allowBluetoothA2DP]
Hope it will work.希望它会奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.