Our app's main feature is to play a list of audio tracks (local or progressively downloaded file-based audio files).
When a user selects a program, there will be an array of track objects (track id, description, url, etc). To start playback, we instantiate a new AVPlayer and set the track url to the player; when that track finishes (observe AVPlayerItemDidPlayToEndTimeNotification), we release the existing player, and then instantiate a new AVPlayer for the next track.
We have set AVAudioSessionCategoryPlayback when app launches.
We have set AVAudioSession active = YES when a new track is played.
The implementation worked fine for many years. But starting from iOS 12.2, our users started experiencing some playback problems such as:
1. Failed to play the next track automatically.
-- from our logs, we can see that the player has started loading the next track, but then it was stopped (KVO, rate = 0)
2. The controls in Control Center were missing; it only showed "Music". It also seemed to affect AirPlay and Bluetooth (car).
We cannot always reproduce the problems so it is difficult for us to debug. Please advise if there are anything that we need to update regarding iOS 12.2, or any solutions or best practices for implementing an audio player for playlist playback.
Thanks.