Closed defagos closed 4 years ago
~We should also add some UT for pause / stop / etc. while preparing to play.~ Done.
It's funnier than expected: The player item never reaches AVPlayerItemStatusReadyToPlay
(video and audio) if the app is sent to the background while preparing to play. Once the application is resumed this status is reached immediately, and playback starts.
The issue was first reported with our Letterbox player, but I thought the culprit was Media Player. It does not seem so. I have opened a similar issue for Letterbox and closed this one.
If the application is sent to the background while the player is still preparing (can be simulated with the network link conditioner), the completion handler will be called when the player is ready, at which point a call to
-play
from this handler might start playback in background.While this is perfectly acceptable for audio or for video background playback if allowed, this should not occur if background behavior detaches the view (in which case we should probably pause the playback to simulate the associated effect).
I naively see two possible fixes:
-play
from the handler).-pause
onAVPlayer
after the completion handler has been called, ifSRGMediaPlayerViewBackgroundBehaviorAttached
and we know that the loaded content is a video. This seems better to me. We probably have to also check AirPlay status or other settings which might affect this behavior.