Skip to content

Commit

Permalink
Add constructor to PillarboxPlayer that takes a Clock for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 authored and StaehliJ committed Feb 8, 2024
1 parent 7ea71bc commit eaa43ab
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
package ch.srgssr.pillarbox.player

import android.content.Context
import androidx.annotation.VisibleForTesting
import androidx.media3.common.MediaItem
import androidx.media3.common.PlaybackException
import androidx.media3.common.PlaybackParameters
import androidx.media3.common.Player
import androidx.media3.common.Timeline.Window
import androidx.media3.common.TrackSelectionParameters
import androidx.media3.common.util.Clock
import androidx.media3.datasource.DataSource
import androidx.media3.datasource.DefaultHttpDataSource
import androidx.media3.exoplayer.DefaultRenderersFactory
Expand Down Expand Up @@ -86,8 +88,28 @@ class PillarboxPlayer internal constructor(
loadControl: LoadControl = PillarboxLoadControl(),
mediaItemTrackerProvider: MediaItemTrackerProvider = MediaItemTrackerRepository(),
seekIncrement: SeekIncrement = SeekIncrement()
) : this(
context = context,
mediaItemSource = mediaItemSource,
dataSourceFactory = dataSourceFactory,
loadControl = loadControl,
mediaItemTrackerProvider = mediaItemTrackerProvider,
seekIncrement = seekIncrement,
clock = Clock.DEFAULT,
)

@VisibleForTesting
constructor(
context: Context,
mediaItemSource: MediaItemSource,
dataSourceFactory: DataSource.Factory,
loadControl: LoadControl,
mediaItemTrackerProvider: MediaItemTrackerProvider,
seekIncrement: SeekIncrement,
clock: Clock,
) : this(
ExoPlayer.Builder(context)
.setClock(clock)
.setUsePlatformDiagnostics(false)
.setSeekIncrements(seekIncrement)
.setRenderersFactory(
Expand Down

0 comments on commit eaa43ab

Please sign in to comment.