AVAudioSessionErrorCodeCannotInterruptOthers

When I receive the InterruptionBegan notification (the interruption type is AVAudioSessionInterruptionTypeBegan) , I pause playing music. When I receive the InterruptionEnded notification (the interruption type is AVAudioSessionInterruptionTypeEnded), I resume playing music. however, sometimes i has got the error code: AVAudioSessionErrorCodeCannotInterruptOthers (560557684)

If some malicious app to take up the audio, which leads to the third party app music playback recovery fails, an error AVAudioSessionErrorCodeCannotInterruptOthers.

In this case, can we know which apps are maliciously hogging the audio?

Answered by Engineer in 788566022

Please refer to the documentation for AVAudioSession.ErrorCode.cannotInterruptOthers. It states that you get this error when trying to activate in the background an audio session that is not mixable, that is, an audio session that does not include the mixWithOthers option, for example.

Please also see AVAudioSession.InterruptionOptions.shouldResume for a discussion on how to correctly handle an interruption notification of type AVAudioSession.InterruptionType.ended. It's not always appropriate to resume audio playback without user input.

Please refer to the documentation for AVAudioSession.ErrorCode.cannotInterruptOthers. It states that you get this error when trying to activate in the background an audio session that is not mixable, that is, an audio session that does not include the mixWithOthers option, for example.

Please also see AVAudioSession.InterruptionOptions.shouldResume for a discussion on how to correctly handle an interruption notification of type AVAudioSession.InterruptionType.ended. It's not always appropriate to resume audio playback without user input.

@Engineer

Yes, we are to judge the AVAudioSessionInterruptionOptionShouldResume, to restore the audio playback.

We have been online for a long time and have been able to resume audio playback normally.

But recently we've had a lot of user feedback as to why the audio won't resume playing.

Based on this feedback, we checked and found that there were some apps that did not play audio but occupied audio all the time. For example, when a user was using the wechat app, after sending a voice message, we received a notification to resume audio playback, and wechat did not play audio either. But we resume play times wrong AVAudioSessionErrorCodeCannotInterruptOthers.

After that, we gave feedback to the wechat app and fixed the problem. But we still have some users feedback this problem, we do not know which app is maliciously occupying audio, so we do not know which aspect to troubleshoot the problem.

We pay close attention to user feedback and hope it can help us solve user experience problems. @Engineer

AVAudioSessionErrorCodeCannotInterruptOthers
 
 
Q