AVPlayerViewController prevents other apps from resuming audio playing

Originator:an00na
Number:rdar://31733529 Date Originated:April 20, 2017 10:21 AM
Status:Closed Resolved:iOS 11
Product:iOS + SDK Product Version:10.3
Classification:Serious Bug Reproducible:Always
 
Area:
AVkit


Summary:
I use `AVPlayerViewController` to play short videos in my app.

If there is an app playing audio in background before user plays a video in my app, I want the background audio playing of the other app to resume after my video player is dismissed. I use `AVAudioSession.setActive(false, with: .notifyOthersOnDeactivation)` to do that. 

Even though Apple's Music app and Podcasts app do resume playing after I call `AVAudioSession.setActive(false, with: .notifyOthersOnDeactivation)`—won't resume without the call so it means this call does have effect—none of the 3rd party music or podcast apps that I tested(Spotify, SoundCloud, Amazon Music, Overcast) do.

At first I thought it might be these 3rd party apps' fault. But then I tested them with the official Twitter app and found they can resume audio playback after video playing in Twitter app. 

So I used DTS(case number 660336191) to ask for help from Apple engineers. After several back and forth we finally confirmed that it is an issue of AVPlayerViewController. Using AVPlayerLayer can avoid this issue.

However, the reason I'm using AVPlayerViewController is exactly to avoid using AVPlayerLayer directly. AVPlayerViewController is a turnkey solution for video playback for apps wherein the standard controls are good enough. My app is such an app. If I have to use AVPlayerLayer and have to emulate all the standard controls and features of AVPlayerViewController, what's the point of iOS offering AVPlayerViewController? So I believe it is a bug of AVPlayerViewController that should be fixed asap.


Steps to Reproduce:

Sample app with Apple Music and Podcasts:

1. Play some music or podcast in Apple Music or Podcasts.
2. Launch sample app.
3. Tap Play.
4. Wait until video starts playing.
5. Tap Done to dismiss AVPlayerViewController.
6. Notice Apple Music or Podcasts resumes audio playback.


Sample app with 3rd party apps:

1. Play some music or podcast in Spotify, SoundCloud, Amazon Music, or Overcast.
2. Launch sample app.
3. Tap Play.
4. Wait until video starts playing.
5. Tap Done to dismiss AVPlayerViewController.
6. Notice the 3rd party app doesn't resume audio playback.


Twitter app with 3rd party apps(as an example of AVPlayerLayer working): 

1. Play some music or podcast in Spotify, SoundCloud, Amazon Music, or Overcast.
2. Launch Twitter app.
3. Find some tweet with video, like this: https://twitter.com/an0/status/824292924368228361
4. Play the video.
5. Dismiss the video. You may also need to dismiss the whole tweet or scroll it out of bounds to make sure its video playback stops.
6. Notice the 3rd party app resumes audio playback.

Expected Results:
AVPlayerViewController should support audio resuming of other apps.

Observed Results:
AVPlayerViewController doesn't support audio resuming of other apps.

Code:
https://cloudup.com/cTrxy7AcpUV

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!