ExoPlayer CacheDataSource FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS

17 Views Asked by At

If I pass the CacheDataSource.FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS flag to CacheDataSource.Factory, the mp4 will not be cached as well.

It seems that the internal function CacheDataSource.shouldIgnoreCacheForRequest always returns true.

Here is my code:

val dsf = CacheDataSource.Factory()
    .setUpstreamDataSourceFactory(
        OkHttpDataSource.Factory(okHttpClient)
            .setUserAgent(userAgent)
        )
    .setCache(cache)
    .setFlags(CacheDataSource.FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS)
val msf = efaultMediaSourceFactory(dsf)
val mediaItem = MediaItem.fromUri(url)
val mediaSource: MediaSource = msf.createMediaSource(mediaItem)
player.setMediaSource(mediaSource)
player.prepare()

Here is the test url: https://media.w3.org/2010/05/sintel/trailer.mp4

When I unset the flag, all streams will be cached.

0

There are 0 best solutions below