-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom video loader caching technique
This commit brings significant improvements to the video cache feature. Previously, the cache would merely download the video when requested, in parallel with AVPlayer which also triggers a video download. The video cache has been updated to tap into the AVPlayer loading process, removing the download duplication. Here is how that works: 1. The player requests an AVAsset from the cache. 2. The cache will return a cached asset if possible, or a special AVURLAsset with a custom `AVAssetResourceLoaderDelegate`. 3. The video player will start sending loading requests to this loader delegate. 4. Upon receiving the first request, the loader delegate begins to download the video data on the background. 5. Upon receiving these requests, the loader delegate will also record the requests, so that it can serve them once possible 6. The loader delegate keeps track of all video data chunks as it receives them from the download task, through the `URLSessionDataDelegate` and `URLSessionTaskDelegate` protocols 7. As it receives data, it checks all pending loading requests from the AVPlayer, and fulfills them as soon as possible 8. If the download fails (e.g. timeout errors, loss of connection), it attempts to restart the download. 9. If the download succeeds, it saves the video to the cache on disk Closes: #1717 Changelog-Added: Add video cache to save network bandwidth Signed-off-by: Daniel D’Aquino <[email protected]> Link: [email protected] Signed-off-by: William Casarin <[email protected]>
- Loading branch information
1 parent
e946c61
commit 8b60fa1
Showing
2 changed files
with
300 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters