AVPlayer fails to play video sometimes

跟風遠走 提交于 2019-12-03 03:28:47

Search Error

I believe there are a lot of people, like me, are looking for the solution of this problem.

I spent a whole afternoon's time, finally solved the problem.

On the question, an error occurred when the video starts playing.

such as:

Domain=AVFoundationErrorDomain Code=-11850 "Operation Stopped"

then I search this error number, and find it:

AVErrorServerIncorrectlyConfigured = -11850

In Apple's Document, I find some information about this error.

The HTTP server sending the media resource is not configured as expected. This might mean that the server does not support byte range requests.

Find Error

So, we should understand that this is a server problem.

Now, we play a video, and grab all http request for analysis.

Will find that AVPlayerItem sends an HTTP request.

when AVPlayerItem receive a video URL , it do the following task:

  1. Send a bytes request HTTP Request, and range = 0 -1
  2. If the response code is 206 and return 1 bytes data, It do the 3th task, if not, AVErrorServerIncorrectlyConfigured error occurred.
  3. continue send other HTTP Request, to download segment of All duration. and the response of VideoData code must be 206

In my situation , when send range[0-1] HTTP request, the server side give me a 200 OK response, So error occurred.

Result

So, you need to ask your server engineer to detect all response who return.

I wish it could help you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!