I'm currently having some troubles using AVPlayer and AVAsset in order to cast a video to an external screen using AirPlay.
After adding the AVRoutePickerView in order to have the AirPlay button, I was able to successfully cast videos to use AirPlay, creating an AVAsset from a remote URL.
If I try the same thing with a video file that was previously downloaded from the app (and it is still inside the internal app storage), AVPlayer fails and gives me an error code (-11870). The local video still plays correctly without AirPlay enabled.
After a couple of searches, I was able to find that the error code refers to externalPlaybackNotSupportedForAsset, though there is no further explanation on this or any mention of this error.
I stumbled upon this issue regarding AVAssetReferenceRestrictions and thought it could help me fix the issue, but even after changing the restriction parameter or setting the options: argument to nil when initializing the AVAsset object didn't work.
Worth to note the fact that also casting using Google Cast does not work for local files, whereas remote video files are casting correctly.
Does anyone know how to deal with this issue?
I'm using XCode 11 and an iPhone 6S with iOS 13.5.1.
Kind Regards