-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Gaëtan Muller <[email protected]>
- Loading branch information
Showing
37 changed files
with
1,041 additions
and
853 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 0 additions & 128 deletions
128
pillarbox-core-business/src/main/java/ch/srgssr/pillarbox/core/business/DefaultPillarbox.kt
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
pillarbox-core-business/src/main/java/ch/srgssr/pillarbox/core/business/PillarboxSRG.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.core.business | ||
|
||
import android.content.Context | ||
import androidx.media3.exoplayer.ExoPlayer | ||
import ch.srgssr.pillarbox.core.business.source.SRGAssetLoader | ||
import ch.srgssr.pillarbox.core.business.source.SRGAssetLoaderConfig | ||
import ch.srgssr.pillarbox.player.PillarboxBuilder | ||
import ch.srgssr.pillarbox.player.PillarboxDsl | ||
import ch.srgssr.pillarbox.player.PillarboxExoPlayer | ||
import ch.srgssr.pillarbox.player.PlayerConfig | ||
import kotlin.time.Duration.Companion.seconds | ||
|
||
/** | ||
* Pillarbox ExoPlayer configured for the SRG SSR. | ||
* | ||
* @param context The [Context]. | ||
* @param builder The builder. | ||
* @receiver [SRG.Builder]. | ||
* @return The configured [PillarboxExoplayer] for SRG SSR. | ||
*/ | ||
@Suppress("FunctionName") | ||
@PillarboxDsl | ||
fun PillarboxExoplayer( | ||
context: Context, | ||
builder: SRG.Builder.() -> Unit = {}, | ||
): PillarboxExoPlayer { | ||
return SRG.create() | ||
.apply(builder) | ||
.create(context) | ||
} | ||
|
||
/** | ||
* Pillarbox player configuration for the SRG. | ||
* It sets up all SRG components by default. | ||
*/ | ||
@Suppress("MatchingDeclarationName") | ||
object SRG : PlayerConfig<SRG.Builder> { | ||
|
||
override fun create(): Builder { | ||
return Builder() | ||
} | ||
|
||
/** | ||
* Builder for the SRG. | ||
*/ | ||
class Builder : PillarboxBuilder() { | ||
init { | ||
val url = if (BuildConfig.DEBUG) "https://dev.monitoring.pillarbox.ch/api/events" else "https://monitoring.pillarbox.ch/api/events" | ||
monitoring(url) | ||
seekForwardIncrement(30.seconds) | ||
seekBackwardIncrement(10.seconds) | ||
} | ||
|
||
private var srgAssetLoader: SRGAssetLoader? = null | ||
|
||
/** | ||
* Configure a [SRGAssetLoader]. | ||
* | ||
* @param context The [Context]. | ||
* @param block The block to configure a [SRGAssetLoader]. | ||
* @receiver [SRGAssetLoaderConfig]. | ||
*/ | ||
fun srgAssetLoader(context: Context, block: SRGAssetLoaderConfig.() -> Unit) { | ||
check(srgAssetLoader == null) | ||
srgAssetLoader = SRGAssetLoader(context, block) | ||
.also(::addAssetLoader) | ||
} | ||
|
||
override fun createExoPlayerBuilder(context: Context): ExoPlayer.Builder { | ||
if (srgAssetLoader == null) srgAssetLoader(context) {} | ||
return super.createExoPlayerBuilder(context) | ||
} | ||
} | ||
} |
Oops, something went wrong.