gpt4 book ai didi

ios - 崩溃 : AVAudioSession Notify Thread in iOS

转载 作者:可可西里 更新时间:2023-11-01 05:42:50 30 4
gpt4 key购买 nike

我收到 AudioToolBox 中发生的 EXC_BAD_ACCESS 崩溃。如何正确处理中断?

请查看 crashlytics 屏幕截图以获取更多信息。 crashlytics screenshot

最佳答案

当我接到电话/faceTime 通话时,我的音频流播放器崩溃了。它实际上是非 ARC 的较旧类(class)。只需为流类添加一个 InterruptionNotification Observer,如果流类正在播放,我们需要在中断开始时暂停播放器实例。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruptionChangeToState:) name:@"ASAudioSessionInterruptionOccuredNotification" object:nil];

- (void)handleInterruptionChangeToState:(NSNotification *)notification {
AudioQueuePropertyID inInterruptionState = (AudioQueuePropertyID) [notification.object unsignedIntValue];
if (inInterruptionState == kAudioSessionBeginInterruption){
if ([self isPlaying]) {
[self pause];

pausedByInterruption = YES; //a global Bool variable
}
}
else if (inInterruptionState == kAudioSessionEndInterruption){
AudioSessionSetActive( true );
if ([self isPaused] && pausedByInterruption) {
[self pause]; // this is actually resume
pausedByInterruption = NO;
}
}

希望对您有所帮助。

关于ios - 崩溃 : AVAudioSession Notify Thread in iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48501747/

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