Observing values ββon AVPlayerItem in iOS9
I have an application that uses AVPlayer
to play AVPlayerItem
(video) from a remote url. In iOS 6-8 I watched the value AVPlayerItem's
for loadedTimeRanges
to notify me when the playerItem
player is ready to play. This also works when I observe the value for an element duration
.
After upgrading to iOS 9 beta, none of the values ββin AVPlayerItem
that I observe ever turn into a method observeValueForKeyPath
. As if I don't watch them at all. I am still being notified by values ββon AVPlayer
, but not on AVPlayerItem
. Could this be a mistake or change something in the environment here? I can't find anything about this.
To clarify, in iOS 6-8, videos start playing as soon as time ranges are loaded. In iOS9, I am never notified when any time intervals are loaded.
Update
After observing the value status
for, AVPlayerItem
I have now confirmed that the item's status has changed to Failed
. After completing the item NSError
after failing, I get this:
Error Domain=AVFoundationErrorDomain Code=-11800
"The operation could not be completed"
UserInfo=0x146023c90 {NSUnderlyingError=0x144f547d0
"The operation couldnβt be completed. (OSStatus error -1022.)",
NSLocalizedFailureReason=An unknown error occurred (-1022),
NSLocalizedDescription=The operation could not be completed}
source to share
I ran into the same question today. In my case, the video upload failed due to the new app security feature in IOS 9.
You can add a per domain exception to your info.plist like this:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
If you need to download videos from arbitrary domains, you can completely disable application transport protection, although this is not recommended.
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
source to share