gpt4 book ai didi

ios - "try AVAudioSession.sharedInstance().setCategory"仅在设备上返回 nil

转载 作者:搜寻专家 更新时间:2023-10-31 22:38:28 28 4
gpt4 key购买 nike

try AVAudioSession.sharedInstance()
.setCategory(AVAudioSessionCategoryPlayback,
with: AVAudioSessionCategoryOptions(rawValue: UInt(UInt8(AVAudioSessionCategoryOptions.defaultToSpeaker.rawValue)
| UInt8(AVAudioSessionCategoryOptions.allowAirPlay.rawValue)
| UInt8(AVAudioSessionCategoryOptions.allowBluetooth.rawValue)
| UInt8(AVAudioSessionCategoryOptions.allowBluetoothA2DP.rawValue))))

返回错误:

Domain=NSOSStatusErrorDomain Code=-50 "(null)"

最佳答案

对于将来发现此问题的任何人,这里就是解决方案。如果您将 AVAudioSessionCategoryPlayback 更改为 AVAudioSessionCategoryPlayAndRecord,它仅适用于设备,如下所示:

try AVAudioSession.sharedInstance()
.setCategory(AVAudioSessionCategoryPlayAndRecord,
with: AVAudioSessionCategoryOptions(rawValue: UInt(UInt8(AVAudioSessionCategoryOptions.defaultToSpeaker.rawValue)
| UInt8(AVAudioSessionCategoryOptions.allowAirPlay.rawValue)
| UInt8(AVAudioSessionCategoryOptions.allowBluetooth.rawValue)
| UInt8(AVAudioSessionCategoryOptions.allowBluetoothA2DP.rawValue))))

关于ios - "try AVAudioSession.sharedInstance().setCategory"仅在设备上返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52194097/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com