AVPlayerItem enqueued in AVQueuePlayer during AirPlay fails with unknown error

Originator:damian.malarczyk
Number:rdar://39750349 Date Originated:26.04.2018
Status:Open Resolved:
Product:iOS Product Version:iOS 11.3 (15E216) as well as 11.3.1 (15E302)
Classification:AVFoundation Reproducible:Always
 
Area:
AVFoundation

Summary:
The issue is partially related to rdar://39750116
While streaming to AirPlay using AVQueuePlayer, starting from 2nd enqueued AVPlayerItem, the items fail with `unknown` error as soon the playback reaches end. 
2nd and later added items don't ever become `readyToPlay` and remain in `unknown` status until the end of playback. The error log doesn't provide any more specific information for the failure reason. 
While AirPlay is disconnected the player and its current item immediately update their statuses to proper values.

Steps to Reproduce:
1. Connect to AirPlay
2. Add 3 items to the player queue
3. Skip (or watch till end) the first item
4. Watch the second item till the end 

Expected Results:
Third item starts playing properly and no errors are reported. 

Actual Results:
Alert with failure is shown. The second item fails with `unknown` error code. Error log does not provide more information about the failure reason. 

Version/Build:
iOS 11.3 (15E216) as well as 11.3.1 (15E302)
tvOS 11.3 (15L211)

Configuration:
I've included modified AVFoundationQueuePlayer demo project with AirPlay support, with resources changed to ones at - https://developer.apple.com/streaming/examples/ - as old streams are no longer accessible due to expired SSL certificate.

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!