AVPlayer有时无法播放视频

时间:2023-01-23 22:52:24

AVPlayer有时无法播放视频

I'm having grid of videos, AVPlayer sometimes fail to play video and showing this disabled icon with following error,

我有视频网格,AVPlayer有时无法播放视频并显示此禁用图标,但有以下错误,

Domain=AVFoundationErrorDomain Code=-11850 "Operation Stopped" UserInfo={NSUnderlyingError=0x7f927ede4210
{Error Domain=NSOSStatusErrorDomain Code=-12939 "(null)"}
, NSLocalizedFailureReason=The server is not correctly configured., NSLocalizedDescription=Operation Stopped})

but same video getting played later on, so it is random issue. Any help on what's going wrong?

但同样的视频后来播放,所以这是随机问题。对出了什么问题的任何帮助?

1 个解决方案

#1


3  

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.

在Apple的文档中,我找到了有关此错误的一些信息。

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

发送媒体资源的HTTP服务器未按预期配置。这可能意味着服务器不支持字节范围请求。

Find Error

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

所以,我们应该明白这是一个服务器问题。

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

现在,我们播放视频,并获取所有http请求进行分析。

Will find that AVPlayerItem sends an HTTP request.

会发现AVPlayerItem发送HTTP请求。

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

当AVPlayerItem收到视频URL时,它执行以下任务:

  1. Send a bytes request HTTP Request, and range = 0 -1
  2. 发送字节请求HTTP请求,范围= 0 -1

  3. If the response code is 206 and return 1 bytes data, It do the 3th task, if not, AVErrorServerIncorrectlyConfigured error occurred.
  4. 如果响应代码为206并返回1字节数据,则执行第3个任务,否则,发生AVErrorServerIncorrectlyConfigured错误。

  5. continue send other HTTP Request, to download segment of All duration. and the response of VideoData code must be 206
  6. 继续发送其他HTTP请求,下载所有持续时间段。并且VideoData代码的响应必须为206

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

在我的情况下,当发送范围[0-1] HTTP请求时,服务器端给我200 OK响应,因此发生错误。

Result

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

因此,您需要让服务器工程师检测所有返回的响应。

I wish it could help you.

我希望它可以帮助你。

#1


3  

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.

在Apple的文档中,我找到了有关此错误的一些信息。

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

发送媒体资源的HTTP服务器未按预期配置。这可能意味着服务器不支持字节范围请求。

Find Error

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

所以,我们应该明白这是一个服务器问题。

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

现在,我们播放视频,并获取所有http请求进行分析。

Will find that AVPlayerItem sends an HTTP request.

会发现AVPlayerItem发送HTTP请求。

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

当AVPlayerItem收到视频URL时,它执行以下任务:

  1. Send a bytes request HTTP Request, and range = 0 -1
  2. 发送字节请求HTTP请求,范围= 0 -1

  3. If the response code is 206 and return 1 bytes data, It do the 3th task, if not, AVErrorServerIncorrectlyConfigured error occurred.
  4. 如果响应代码为206并返回1字节数据,则执行第3个任务,否则,发生AVErrorServerIncorrectlyConfigured错误。

  5. continue send other HTTP Request, to download segment of All duration. and the response of VideoData code must be 206
  6. 继续发送其他HTTP请求,下载所有持续时间段。并且VideoData代码的响应必须为206

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

在我的情况下,当发送范围[0-1] HTTP请求时,服务器端给我200 OK响应,因此发生错误。

Result

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

因此,您需要让服务器工程师检测所有返回的响应。

I wish it could help you.

我希望它可以帮助你。