Our team have an app to play back m4a resources online using the avplayer. Recently, there are some users complaining the playback is keep failing and we have no idea the reason behind this.
We checked the user log and the avplayer error log are as follow (for multiple failed instance):
- avPlayer.currentItem.error = Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16155), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x280e6ef10 {Error Domain=NSOSStatusErrorDomain Code=-16155 "(null)"}}
- avPlayer.currentItem.error = Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (606068440), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x280e9f8d0 {Error Domain=NSOSStatusErrorDomain Code=606068440 "(null)"}}
- avPlayer.currentItem.error = Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (1705376704), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x281ec60d0 {Error Domain=NSOSStatusErrorDomain Code=1705376704 "(null)"}}
The normal flow for us to start playing: (Work as expected for majority of user)
1. [[AVAudioSession sharedInstance] setActive:YES error:&activationError];
2. call [avplayer play]
3. the audio started to play successfully
Failed scenario: (For some users, this scenario keeps happening)
1. The activation error returns Error Domain=NSOSStatusErrorDomain Code=2003329396 "(null)"
2. We logged the [AVAudioSession sharedInstance].category becomes empty
3. The mediaServicesWereReset notification is received
4. the avplayer failed to play and the one of the above avplayer item error is observed
When the user failed once, he cannot play any audio resources in our app and the scenario is keep repeating.
We would like to know:
1. Why would this occur on certain user devices?
2. How to prevent the problem occurs?
3. Is there a way to recover from the lost mediaService? so that even if the error occurs once, the user can still play other resources in our app.
We cannot produce the fail scenario by ourselves even we tried the Reset Media Services in developer menu, the behaviour is not exactly the same. Look forward to any help from the community and thanks.