Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cache from ExoPlayerConfig to create a new pool #171

Merged
merged 7 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions kohii-exoplayer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion libs.versions.android.target.sdk.get().toInteger()

defaultConfig {
minSdkVersion libs.versions.android.min.sdk.get()
targetSdkVersion libs.versions.android.target.sdk.get()
Expand Down
23 changes: 12 additions & 11 deletions kohii-exoplayer/src/main/java/kohii/v1/exoplayer/ExoPlayerConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,16 @@ fun ExoPlayerConfig.createDefaultPlayerPool(
context: Context,
userAgent: String
) = ExoPlayerPool(
context = context.applicationContext,
userAgent = userAgent,
clock = clock,
bandwidthMeterFactory = this,
trackSelectorFactory = this,
loadControlFactory = this,
renderersFactory = DefaultRenderersFactory(context.applicationContext)
.setEnableDecoderFallback(enableDecoderFallback)
.setAllowedVideoJoiningTimeMs(allowedVideoJoiningTimeMs)
.setExtensionRendererMode(extensionRendererMode)
.setMediaCodecSelector(mediaCodecSelector)
context = context.applicationContext,
userAgent = userAgent,
clock = clock,
bandwidthMeterFactory = this,
trackSelectorFactory = this,
loadControlFactory = this,
renderersFactory = DefaultRenderersFactory(context.applicationContext)
.setEnableDecoderFallback(enableDecoderFallback)
.setAllowedVideoJoiningTimeMs(allowedVideoJoiningTimeMs)
.setExtensionRendererMode(extensionRendererMode)
.setMediaCodecSelector(mediaCodecSelector),
cache = cache,
)
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ class ExoPlayerPool(
private val loadControlFactory: LoadControlFactory = ExoPlayerConfig.DEFAULT,
private val renderersFactory: RenderersFactory =
DefaultRenderersFactory(context.applicationContext),
private val cache: Cache? = null,
// DefaultMediaSourceFactory
// @RestrictTo(LIBRARY_GROUP)
// Note: Only used within the library group. Client must not access this field.
val defaultMediaSourceFactory: DefaultMediaSourceFactory = with(context) {
val httpDataSource = DefaultHttpDataSource.Factory().setUserAgent(userAgent)

// DefaultMediaSourceFactory
val mediaCache: Cache = ExoPlayerCache.lruCacheSingleton.get(context)
val mediaCache: Cache = cache ?: ExoPlayerCache.lruCacheSingleton.get(context)
val upstreamFactory = DefaultDataSource.Factory(context, httpDataSource)
val drmSessionManagerProvider = DefaultDrmSessionManagerProvider()
drmSessionManagerProvider.setDrmHttpDataSourceFactory(httpDataSource)
Expand Down
Loading