-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content protection errors are never forwarded to AVPlayer #3
Comments
I discovered this issue has been fixed in iOS 15. This requires two things, though:
If both conditions are met the error including its localized description are retrieved from the player item when its status changed to failed:
Failing to fulfill any of these requirements leads to an anonymous error:
On iOS 14 the error code is received but the message is still lost:
Check the attached sample project. |
Update: This does not suffice. If loading
|
Conditions for correct error propagation changed during iOS 16.1 betas but the RC made changes again. The best way to throw errors from a resource loader, either from Objective-C or Swift code, is the following:
Note that the error received on the |
Due to an Apple AVFoundation bug, calling
[AVAssetResourceLoadingRequest finishLoadingWithError:]
from a resource loader delegate implementation to report an error does not correctly forward this error information to theAVPlayer
.Instead, the original error is somehow internally (and incorrectly) transformed into another error. If the code used for the original error is by any chance a known error from the
NSPOSIXErrorDomain
domain, the error is for example turned into anNSPOSIXErrorDomain
with the same code. The original domain and the associated user info dictionary are completely lost in the process. This new incorrect error is then attached to theAVPlayerItem
and can be read after its state changed toAVPlayerItemStatusFailed
(observed by KVO).The
errorLog
attached to the item is empty and is therefore not helpful.We should file a bug report for Apple about this issue.
Possible workaround
A possible workaround would be to access the resource loader attached to an
AVURLAsset
with-[AVPlayerItem asset]
(cast toAVURLAsset
) and theresourceLoader.delegate
path, after the status changed toAVPlayerItemStatusFailed
. Of course, since there is noerror
property on the delegate, being able to read it in SRG Media Player would require this library to define a protocol, which is probably overkill and ugly.Consequences
AVPlayer
orSRGMediaPlayerController
level properly. There is therefore no way to implement dedicated instruction messages at the moment.Improvements if fixed
If Apple fixes this bug, we can make the error header public.
The text was updated successfully, but these errors were encountered: