3

我有一个用于从远程 URLAVPlayer播放(视频)的应用程序。AVPlayerItem在 iOS 6-8 中,我一直在观察AVPlayerItem's值,以便在播放器准备好播放loadedTimeRanges时通知我。我相信,playerItem这在观察 item 的值时也有效。duration

更新到 iOS 9 测试版后,AVPlayerItem我观察到的值都没有进入observeValueForKeyPath- 方法。就好像我根本没有观察他们一样。我仍然收到 on 值的通知AVPlayer,但不是 on AVPlayerItem。这可能是一个错误,还是这里的环境发生了一些变化?我找不到任何关于这个的..

为了澄清起见,在 iOS 6-8 中,只要有任何加载的时间范围,视频就会开始播放。在 iOS9 中,我永远不会在加载任何时间范围时收到通知。

更新

在观察了 的值后statusAVPlayerItem我现在确认该项目的状态已更改为FailedNSError通过在失败后注销该项目,我得到了这个:

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}
4

1 回答 1

5

我今天遇到了同样的问题。就我而言,由于 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>

如果您需要从任意域加载视频,您可以完全禁用 App Transport Security,但不建议这样做。

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>
于 2015-07-16T01:30:38.560 回答