Skip to content

Commit 3a78e7b

Browse files
authored
Add SeekableLiveConfig to the PillarboxBuilder (#1180)
1 parent ebf7b33 commit 3a78e7b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

pillarbox-player/src/main/java/ch/srgssr/pillarbox/player/PillarboxBuilder.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import ch.srgssr.pillarbox.player.monitoring.NoOp
2727
import ch.srgssr.pillarbox.player.monitoring.Remote
2828
import ch.srgssr.pillarbox.player.monitoring.Remote.config
2929
import ch.srgssr.pillarbox.player.source.PillarboxMediaSourceFactory
30+
import ch.srgssr.pillarbox.player.source.SeekableLiveConfig
3031
import kotlinx.coroutines.CoroutineScope
3132
import kotlinx.coroutines.Dispatchers
3233
import okhttp3.OkHttpClient
@@ -65,7 +66,8 @@ abstract class PillarboxBuilder {
6566
private var playbackLooper: Looper? = null
6667
private var seekBackwardIncrement: Duration = C.DEFAULT_SEEK_BACK_INCREMENT_MS.milliseconds
6768
private var seekForwardIncrement: Duration = C.DEFAULT_SEEK_FORWARD_INCREMENT_MS.milliseconds
68-
private var preloadConfiguration = ExoPlayer.PreloadConfiguration.DEFAULT
69+
private var preloadConfiguration: ExoPlayer.PreloadConfiguration = ExoPlayer.PreloadConfiguration.DEFAULT
70+
private var seekableLiveConfig: SeekableLiveConfig = SeekableLiveConfig()
6971

7072
/**
7173
* Registers a custom [AssetLoader] with the [PillarboxExoPlayer].
@@ -184,6 +186,15 @@ abstract class PillarboxBuilder {
184186
this.playbackLooper = playbackLooper
185187
}
186188

189+
/**
190+
* Sets the [SeekableLiveConfig] used by the player. It customizes the way the player considers a live is seekable or not.
191+
*
192+
* @param seekableLiveConfig The [SeekableLiveConfig] to be used by the player
193+
*/
194+
fun seekableLiveConfig(seekableLiveConfig: SeekableLiveConfig) {
195+
this.seekableLiveConfig = seekableLiveConfig
196+
}
197+
187198
/**
188199
* Sets the duration by which the player seeks backward when performing a "seek backward" operation.
189200
*
@@ -237,7 +248,7 @@ abstract class PillarboxBuilder {
237248
require(seekBackwardIncrement > ZERO) { "Seek backward increment needs to be greater than zero" }
238249
require(seekForwardIncrement > ZERO) { "Seek forward increment needs to be greater than zero" }
239250

240-
val mediaSourceFactory = PillarboxMediaSourceFactory(context)
251+
val mediaSourceFactory = PillarboxMediaSourceFactory(context, seekableLiveConfig)
241252
assetLoaders.forEach { assetLoader ->
242253
mediaSourceFactory.addAssetLoader(assetLoader)
243254
}

0 commit comments

Comments
 (0)