首页 文章

AVPlayer永远不会准备好玩

提问于
浏览
6

我有 AVPlayer 正在加载远程媒体 URLHLS stream),有时播放器永远不准备播放,但没有出现错误 . 是否有其他地方可能出现错误或检查是否仍在加载 AVPlayerItem 的方法?

我有 KVO 的速率,状态和播放可能跟上,当视频不在特定视频上发生时,永远不会被调用 .

我可以采取哪些其他步骤来调试此问题?还有其他地方可以检查错误或状态吗?

更多信息检查:播放缓冲区为空:true播放缓冲区已满:false

2 回答

  • 1

    我们的解决方案是在重用播放器之前,我们使用 player.replaceCurrentItemWithPlayerItem(nil) 取消分配AVPlayer . 替换当前项目的某些原因有时会导致问题 . 我们还确保我们的视频按顺序加载,而不是一次性加载 . 这似乎解决了我们的问题 .

  • 2

    为了能够从您的应用程序中加载来自远程服务器的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 .

相关问题