谷歌地图的 AVAudioSession 中断

问题描述

我有一个通过 AVAudioSession 播放和录制音频的 iOS 应用,我希望用户能够在使用地图应用时播放音频。理想情况下,每当地图应用开始说话或播放音频时,我的应用都会暂停播放,并在播放完成后继续播放。

我试过像这样收听通知

[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(routeInterruption:) name:AVAudioSessionRouteChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(interruption:) name:AVAudioSessionInterruptionNotification object:nil];
[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(silenceNotif:) name:AVAudioSessionSilenceSecondaryAudioHintNotification object:nil];

我不确定应该使用什么正确的通知,我尝试了所有看起来有意义的通知。到目前为止,我只能检测到我在自己的应用中播放的音频,而无法检测到 Google 地图等开始说话时播放的音频。

是否有不同的方式来侦听来自外部应用的音频事件、我当前未观察到的另一个事件,或者我应该尝试解决此问题的其他任何方法

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)