How to improve cache and network in exoplayer
- Dominant language
- Java
- Stars
- 21.9k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I was working on a video banner which user swipe a banner then the banner plays a video.
It is pretty much like a horizontal version of TikTok that users swipe horizontally.
Here is my basic design. I placed an instsance of `ExoPlayer` in a horizontal `RecyclerView` and a `PlayerView` will be added dynamically based on the scroll event. So, on a swipe event, previous `PlayerView` will be removed and new instance of a `PlayerView` will be added to the `RecyclerView`. Of course, new uri sources will be passed into the `player`. In addition to that, I wanted to add caching features, so I made an instance of `SimpleCache` in `Application` level scope and triggered a `Service` that performs the caching job with CacheUtil class.
- `RecyclerView`: contains one `ExoPlayer` and call `CacheUtil.getCached()` on a swipe event while replacing `PlayerView`.
- `Activity`: In `onCreate()`, start the `Service` to cache the videos
- `Service`: Call`CachUtil.cache()` method in `coroutine`.
1. I am planning to migrate this banner to my company's project. They already setup Retrofit/OkHttp3 connections with their own tokens and headers. So, I might need to customize the HttpDataSource stuffs. However, it is so difficult to find a reference or detailed example of customizing network connections when using `ExoPlayer`. Can you please give me an advice?
2. How do I manage the cache? to be specific, How do I manage size of the cached files? The cached videos will be huge because the videos have high resolution. I used `LeastRecentlyUsedCacheEvictor`
3. Is there a way to have a mixed server response that contains uris, strings, or integers?
Thank you in advance.
by the way, version is 2.10
Contributor guide
Assessment
This issue has not been assessed yet.