尝试使用 MPMoviePlayerViewController 观看视频时出现此错误。视频网址在 Safari 浏览器上运行良好,但在 iPhone/iPad 上却不行。
NSConcreteNotification 0x122b9ab0 {name = MPMoviePlayerPlaybackDidFinishNotification; object = <MPMoviePlayerController: 0x12243330>; userInfo = {
MPMoviePlayerPlaybackDidFinishReasonUserInfoKey = 1;
error = "Error Domain=MediaPlayerErrorDomain Code=-11829 \"Cannot Open\" UserInfo=0x122bc190 {NSLocalizedDescription=Cannot Open}";
使用 Charles 代理,我可以看到那里的请求:
Status Complete
Response Code 401 Unauthorized
Protocol HTTP/1.1
Method GET
Content-Type text/html
然后
Status Complete
Response Code 206 Partial Content
Protocol HTTP/1.1
Method GET
Content-Type video/mp4
然后
Status Complete
Failure Client closed connection before receiving entire response
Response Code 206 Partial Content
Protocol HTTP/1.1
Method GET
Content-Type video/mp4
同样的问题在这里iOS:播放需要身份验证的视频在 QuickLook 中有效,但在 MPMoviePlayerViewController 中无效