iOS 12.2 AVPlayer failed to play next track and missing in Control Center

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.

Replies

Hi, all we are also facing the same issue, any pointers on what may be causing this?

No, totally no idea...

After googling iOS 12.2 AVPlayer / Control Center related topics, we came across this SO post: https://stackoverflow.com/questions/55725591/ios-12-2-lockscreen-controlos-missing, and started to suspect if the issue was related to the DFPBannerView (kGADAdSizeSmartBannerPortrait) at the bottom of each page. (Google-Mobile-Ads-SDK v7.42.2)


Then we commented out the lines of codes that load the banner request, and distributed a test version through TestFlight. Nearly 90% of the testers reported that they did not experience the problems again with the no-banner version.


Today, we found another SO post (https://stackoverflow.com/questions/56764170/ad-banners-causing-mpnowplayinginfocenter-to-lose-state) which seems to have similar, if not the same, problem.


Do you have any Google Mobile Ads in your app?

We are facing the similar problem as described in the SO link.

Yes we are also showing Google Mobile Ads SDK to show ads.We believed some how Google ADS are responible for this issue, based on that we started our investigation to find the responsible ad causing this issue.


As per our current observation, the responsible AD is an Interstitial Ad (Might be any AD having audio component). We have looked into the content of the responsible AD file (downloaded as html content) and found that it contains some Audio Component and cocos2d code.

We have also verified that this issue is happening only on devices having iOS 12.2 and above.


The hypothesis that whenever an HTML file having some audio component is loaded into UIWebview Audio Session loses its focus, might be true.

We are looking further into this.