Skip to content

Instantly share code, notes, and snippets.

@SG-K
Created June 25, 2025 14:26
Show Gist options
  • Select an option

  • Save SG-K/1af584cbab174557f8259d8daca352ba to your computer and use it in GitHub Desktop.

Select an option

Save SG-K/1af584cbab174557f8259d8daca352ba to your computer and use it in GitHub Desktop.
fun buildOkHttoDataSourceFactory(context: Context): DataSource.Factory {
val simpleCache = ExoPlayerCache.getSimpleCache(context)
val okHttpClient = OkHttpClient.Builder().build()
val okHttpDataSourceFactory = OkHttpDataSource.Factory(okHttpClient)
val cacheDataSourceFactory = CacheDataSource.Factory()
.setCache(simpleCache)
.setUpstreamDataSourceFactory(okHttpDataSourceFactory)
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR)
return cacheDataSourceFactory
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment