Skip to content

[Feature request] Preload #12

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

Open
Ludotrico opened this issue Jun 22, 2021 · 7 comments
Open

[Feature request] Preload #12

Ludotrico opened this issue Jun 22, 2021 · 7 comments

Comments

@Ludotrico
Copy link

Ludotrico commented Jun 22, 2021

Pre-loading is a common use case these days because users expect videos to load instantly in scroll views.

API Details:

  • GLOBAL: preloadByteCount: specify how many bytes at the beginning of the URL to preload.
  • GLOBAL: queueMax: Max number of URLS in the preload queue, if this number is reached upon insertion, remove previous URLS to make space
  • DYNAMIC: networkTaskMax: Max number of concurrent network tasks for preloading at any given time. This is necessary to avoid binging client bandwidth and avoid blocking iOS threads.
  • preload(urls: Array): add the following urls to to the pre-load queue. Make space in queue if queueMax is reached. ONLY preload if:
  1. the current video playing has sufficient play buffer due to good network. If this is not the case, wait until it is to preload.
  2. the networkTaskMax has not been reached.
  • stopPreload(urls: Array): remove urls from pre-load queue and stop associated data tasks immediately. Extremely useful if user back out of page for example.

Let me know if you need help implementing these. Should be relatively straightforward.

@FoksWang
Copy link
Owner

FoksWang commented Jun 23, 2021

Please try this:
playerManager.isEnableMediaCache = true

@Ludotrico
Copy link
Author

@FoksWang I have, this will cache but not preload.

@FoksWang
Copy link
Owner

I understand what you mean. Indeed, this library has no preload features.

@Ludotrico
Copy link
Author

@FoksWang any intention of adding it? I could help.

@FoksWang
Copy link
Owner

@Ludotrico preload is a good idea, especially for the short videos, I can add this feature, and I will mark it to remind myself. However, in terms of time, I am not sure when I can start to do it, because this year is too busy for me.

@Ludotrico
Copy link
Author

@FoksWang I must ask you, why not make your library open source so that others can improve it when you don't have time?

Also, if you do start working on this preload feature, please reach out to me or to a developer that understands the use case well to specify requirements. For example, keeping track of URL tasks and cancelling preloads is extremely important in a tik-tok like video application where videos are in a scroll view.

@FoksWang
Copy link
Owner

@Ludotrico First of all, thank you very much for you want to add more features to this library. I created this library to verify a commercial project in the beginning. The commercial code provides CocoaPods support and guarantees that the source code still belongs to the company (private), which is why it is not open source.

I am working on another media project right now this year, so I will just do some bug fixes. New features will not be added until my media project has reached a stage.

Unless fatal issues, it is not the first priority, please understand.

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