Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification on eager loading. #11

Open
8secz-johndpope opened this issue Aug 14, 2021 · 2 comments
Open

Clarification on eager loading. #11

8secz-johndpope opened this issue Aug 14, 2021 · 2 comments

Comments

@8secz-johndpope
Copy link

EAGER LOADING
This repo by @ChrishonWyllie
https://github.com/ChrishonWyllie/Celestial

Provides an easy way to kick off a download like this
Celestial.shared.startDownload(for: url)

By hooking into uikit method -

extension VideoVC: UICollectionViewDataSourcePrefetching {
    func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {
            //  urls for next video in collectionview
             Celestial.shared.startDownload(for: url) // go and get the video
    }
}

We can eagerly kick off the download in background - no ui /and then user scrolls to video / or navigates to the page where it's needed - it will then automatically intercept the request in background and make plays in player.

Can this repo do this?

@eroscai
Copy link
Owner

eroscai commented Aug 15, 2021

If i understand correctly, you want preload some videos, but don't want them to start playing automatically, wait until the cell slides to the position.

I took a look at the startDownload function of Celestial repo. This function is just to make regular file download request, and then there may be some managers to manage the download status to these files.
This kind of operation may seem to make the video play smoothly when the cell scrolls, but it may cause some side effects. E.g:

  • It will download entire file, if there are many files and size is large, it will affect the current video to be played.
  • If current network is poor, it also affect the current video playing.
  • In most cases, downloading the whole file is a waste.

But if you just want to achieve this function, you can use a dedicated library to pre-downloading, like this one? Then set the downloaded file path to the player when needed, or set remote url if it is not downloaded.

The best solution is to provide a preload function in the library, preload part of the content at the beginning, and then use it in conjunction with the existing cache function. This will take a lot of time to implement, maybe I will do this later if i have enough time.

@8secz-johndpope
Copy link
Author

There's some magic in that - if the player requests the video being downloaded - it will merge the existing request into avplayer loading....
Screen Shot 2021-08-16 at 2 10 41 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants