iOS 10 HLS 404 播放列表错误处理
<p><p>在 iOS 10 中,如果 m3u8 主播放列表请求返回 404,则 AVPlayerItem 上的状态属性不会转换为失败状态 (AVPlayerItemStatusFailed)。这使得错误处理程序无法按照 <a href="https://developer.apple.com/reference/avfoundation/avplayeritem" rel="noreferrer noopener nofollow">https://developer.apple.com/reference/avfoundation/avplayeritem</a> 的 AVPlayerItem 文档中的说明进行操作。 </p>
<p>有没有人找到任何替代方案?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><h2>Swift 4 解决方案</h2>
<p>您可以跟踪 AVPlayerItemNewErrorLogEntry 通知。对于 404 错误,以下代码将打印“HTTP 404: File Not Found”</p>
<pre><code>NotificationCenter.default.addObserver(forName: .AVPlayerItemNewErrorLogEntry, object: avPlayer?.currentItem, queue: .main) { _ in
print(avPlayer.currentItem?.errorLog()?.events.last?.errorComment)
}
</code></pre>
<p>此外,该视频的后半部分包含有关客户端错误处理最佳做法的有用信息。 <a href="https://developer.apple.com/library/content/technotes/tn2224/_index.html" rel="noreferrer noopener nofollow">https://developer.apple.com/library/content/technotes/tn2224/_index.html</a> </p></p>
<p style="font-size: 20px;">关于iOS 10 HLS 404 播放列表错误处理,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/40364444/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/40364444/
</a>
</p>
页:
[1]