我有 AVPlayer 正在加载远程媒体 URL ( HLS stream),有时播放器永远不准备播放,但没有出现错误 . 是否有其他地方可能出现错误或检查是否仍在加载 AVPlayerItem 的方法?
AVPlayer
URL
HLS
AVPlayerItem
我有 KVO 的速率,状态和播放可能跟上,当视频不在特定视频上发生时,永远不会被调用 .
KVO
我可以采取哪些其他步骤来调试此问题?还有其他地方可以检查错误或状态吗?
更多信息检查:播放缓冲区为空:true播放缓冲区已满:false
我们的解决方案是在重用播放器之前,我们使用 player.replaceCurrentItemWithPlayerItem(nil) 取消分配AVPlayer . 替换当前项目的某些原因有时会导致问题 . 我们还确保我们的视频按顺序加载,而不是一次性加载 . 这似乎解决了我们的问题 .
player.replaceCurrentItemWithPlayerItem(nil)
为了能够从您的应用程序中加载来自远程服务器的URL,您必须将其添加到info.plist中
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>mydomain.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSExceptionRequiresForwardSecrecy</key> <true/> <key>NSExceptionMinimumTLSVersion</key> <string>TLSv1.2</string> <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key> <false/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <true/> <key>NSThirdPartyExceptionMinimumTLSVersion</key> <string>TLSv1.2</string> <key>NSRequiresCertificateTransparency</key> <false/> </dict> </dict> </dict>
see the docs
Don 't add the lines exactly as I typed. Configure them for your needs. Note that Apple'的iOS默认配置是期望 https 连接,而不是 http . 您必须将其配置为允许 http .
https
http
2 回答
我们的解决方案是在重用播放器之前,我们使用
player.replaceCurrentItemWithPlayerItem(nil)
取消分配AVPlayer . 替换当前项目的某些原因有时会导致问题 . 我们还确保我们的视频按顺序加载,而不是一次性加载 . 这似乎解决了我们的问题 .为了能够从您的应用程序中加载来自远程服务器的URL,您必须将其添加到info.plist中
see the docs
Don 't add the lines exactly as I typed. Configure them for your needs. Note that Apple'的iOS默认配置是期望
https
连接,而不是http
. 您必须将其配置为允许http
.