Why AVPlayer ask several union range in same session?
Asked Answered
Q

1

7

I'm would to know why AVPlayer ask's union ranges in requests. Example: 1. We have good wi-fi connection. 2. Track with total length = 1000000.

AVPlayer in first will ask bytes=0-1 - its ok, it just "ping" the availability of track.

But after that it will ask bytes=0-999999 - and get content-len 1000000;

And after that it will ask bytes=40000-999999 - and get content-len 599999;

Why it make third request if we must have all data from second request (bytes=0-999999)?

Quartersaw answered 5/8, 2013 at 12:20 Comment(1)
I have a similar question: why does AVPlayer not ask a smaller range in the second request? Isn't the whole point of range is to ask for only partial content?Padlock
Q
0

For those in the future wondering about the same issue: This happens because AVPlayer doesn’t initially know anything about the video. It needs to download the first chunks of the file to read the header and initialization data, typically the first 50k bytes.

After this, AVPlayer will cancel the initial request with the full byte-range, then create a new request with bytes=<0 + downloaded bytes>-<length>. It will download additional bytes, cancel the request, and create a new one.

Therefore, AVPlayer doesn’t download all bytes multiple times. Why Apple uses this strategy is unclear. It is likely for redundancy with limited mobile networks and to support faster seeking.

Quiz answered 21/6 at 17:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.