Sti*_*Sti 3 avfoundation avplayeritem ios9
我有一个用于从远程URL AVPlayer播放AVPlayerItem(视频)的应用程序.在iOS 6-8中,我一直在观察在播放器准备好播放时通知我的AVPlayerItem's价值.我相信,这在观察物品的价值时也有效.loadedTimeRangesplayerItemduration
更新到iOS 9测试版后,AVPlayerItem我观察到的任何值都没有达到observeValueForKeyPath-method.就好像我根本没有观察它们一样.我仍然会收到有关值的通知AVPlayer,但不会通知AVPlayerItem.这可能是一个错误,还是这里的环境发生了变化?我找不到任何关于这个......
为了澄清,在iOS 6-8中,只要有任何加载的时间范围,视频就会开始播放.在iOS9中,我在加载任何时间范围时都不会收到通知.
更新
在观察了我的值后status,AVPlayerItem我现已确认该项的状态已更改为Failed.通过NSError在失败后注销该项目,我得到了这个:
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}
Run Code Online (Sandbox Code Playgroud)
我今天遇到了同样的问题.就我而言,由于iOS 9中新的App Transport Security功能,加载视频失败了.
您可以为info.plist添加每个域的例外,如下所示:
<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>
Run Code Online (Sandbox Code Playgroud)
如果您需要从任意域加载视频,可以完全禁用App Transport Security,但不建议这样做.
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1911 次 |
| 最近记录: |