Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Avfoundation iOS9中AVPlayerItem的观测值_Avfoundation_Ios9_Avplayeritem - Fatal编程技术网

Avfoundation iOS9中AVPlayerItem的观测值

Avfoundation iOS9中AVPlayerItem的观测值,avfoundation,ios9,avplayeritem,Avfoundation,Ios9,Avplayeritem,我有一个应用程序,它使用AVPlayer从远程URL播放AVPlayerItem(视频)。在iOS 6-8中,我一直在观察loadedTimeRanges的AVPlayerItem值,以便在玩家准备播放playerItem时通知我。我相信,当观察项目的持续时间的值时,这也会起作用 更新到iOS 9 beta版后,我观察到的AVPlayerItem上的任何值都不会进入observeValueForKeyPath-方法。就好像我根本没有观察到他们一样。我仍然收到AVPlayer上的值通知,但没有收到

我有一个应用程序,它使用
AVPlayer
从远程URL播放
AVPlayerItem
(视频)。在iOS 6-8中,我一直在观察
loadedTimeRanges
AVPlayerItem
值,以便在玩家准备播放
playerItem
时通知我。我相信,当观察项目的
持续时间的值时,这也会起作用

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

为了澄清,在iOS 6-8中,一旦有任何加载的时间范围,视频就开始播放。在iOS9中,当加载任何时间范围时,我从未收到通知

更新

在观察
AVPlayerItem
的值
status
后,我现在确认该项目的状态已更改为
失败
。通过在失败后注销项目的
n错误
,我得到以下结果:

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}

我今天遇到了同样的问题。在我的例子中,由于iOS 9中新的应用程序传输安全功能,加载视频失败

您可以向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>
NSAppTransportSecurity
NSExceptionDomains
yourserver.com
n包括多个域
NSTemporary ExceptionalLowsInSecureHttpLoads
NSTemporaryExceptionMinimumTLSVersion
TLSv1.1
如果您需要从任意域加载视频,您可以完全禁用应用程序传输安全,但不建议这样做

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>
NSAppTransportSecurity
NSAllowsArbitraryLoads