How to use DownloadManager download range data
- Dominant language
- Java
- Stars
- 21.9k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
## Background
In my project, I use ExoPlayer with version 2.11.8 .
In this version, I use CacheUtil cache some range data to improve first frame time.
sample code like this:
```kotlin
val mp4Url /*a network file uri, it media container type is mp4*/
val upstreamFactory
val simpleCache /*ExoPlayer's SampleCache impl*/
CacheUtil.cache(
DataSpec(Uri.parse(mp4Url),
/*position*/ 0,
/*size*/ 512 * 1024 /*byte*/,
/*custom key*/ mp4Url),
simpleCache,
upstreamFactory,
{ requestLength, bytesCached, _ ->
val downloadPercentage: Double = (bytesCached * 100.0
/ requestLength)
if (downloadPercentage == 100.0) {
Logger.d(TAG, "exo preload finish with 512 KB")
}
},
null
)
```
In this month, I upgrade ExoPlayer version to 2.15.0 .
The "CacheUtil" was removed, I replace it with "CacheWriter".
And In other withe, I found a high-level API "DownloadManager", but I don't know how to use it in my project to implement preload or download some range data.
Contributor guide
Assessment
This issue has not been assessed yet.