微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在其他应用程序中播放音乐后回到应用程序时崩溃

如何解决在其他应用程序中播放音乐后回到应用程序时崩溃

我有带有录音和播放选项的音乐应用程序。

现在,我想改变在立体声扬声器上播放音频的可能性,我正在这样做:

try session.setCategory(.playAndRecord,mode: .default,options: [.allowBluetoothA2DP,.defaultToSpeaker])
try session.setPreferredSampleRate(Double(EngineConfiguration.kSampleRate)) 

当我回到录音时,我切换到

try session.setCategory(.playAndRecord,options: [.allowBluetoothA2DP])

当我转到其他应用程序并在那里播放音乐时,又回到我的应用程序时,我崩溃了:

2020-10-02 16:29:09.692031+0200 MyApp[940:252040] [avae]
AVAEInternal.h:76 required condition is false: [AVAudioEngineGraph.mm:2026:InstallTapOnNode:
(format.sampleRate == inputHWFormat.sampleRate)]

2020-10-02 16:29:09.692900+0200 MyApp[940:252040] *** Terminating app due to uncaught 
exception 'com.apple.coreaudio.avfaudio',reason: 'required condition is false:
format.sampleRate == inputHWFormat.sampleRate'
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio',reason: 'required
condition is false: format.sampleRate == inputHWFormat.sampleRate'

这是我的installTap使用方法

let format: AVAudioFormat = unitMixMic.outputFormat(forBus: 0)
unitMixMic.removeTap(onBus: 0)
unitMixMic.installTap(onBus: 0,bufferSize: EngineConfiguration.kSampleBufferSize,format: format) { [weak self] (buffer: AVAudioPCMBuffer,_: AVAudioTime) in [...] }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。