.apply {
val cache = VideoPlayerCacheManager.getCache()
if (cache != null) {
val cacheDataSourceFactory = CacheDataSource.Factory()
.setCache(cache)
.setUpstreamDataSourceFactory(DefaultDataSource.Factory(context, httpDataSourceFactory))
setMediaSourceFactory(DefaultMediaSourceFactory(cacheDataSourceFactory))
} else {
setMediaSourceFactory(DefaultMediaSourceFactory(httpDataSourceFactory))
}
}
It's now working with OkHttpDataSource. I'm not sure if that is the most elegant API. Maybe accepting the DataSource.Factory itself would be an option?
I'm happy to tidy submit this into a pull request if that helps.
Hi,
I really, really, like this library. Much much easier to use than the 400+ line ExoPlayer "getting started" demo.
I needed to use the OkHttp DataSource (to enable playing videos that a user has downloaded offline via an OkHttp interceptor I made).
The current function signatures don't allow setting the DataSource.Factory. I made a fork with an option for the HttpDataSource here:
https://github.com/UstadMobile/compose-video
Add argument:
Use it:
It's now working with OkHttpDataSource. I'm not sure if that is the most elegant API. Maybe accepting the DataSource.Factory itself would be an option?
I'm happy to tidy submit this into a pull request if that helps.