@@ -17,9 +17,6 @@ import androidx.compose.animation.slideOutHorizontally
1717import androidx.compose.animation.slideOutVertically
1818import androidx.compose.animation.togetherWith
1919import androidx.compose.foundation.background
20- import androidx.compose.foundation.interaction.Interaction
21- import androidx.compose.foundation.interaction.MutableInteractionSource
22- import androidx.compose.foundation.interaction.collectIsPressedAsState
2320import androidx.compose.foundation.layout.Arrangement
2421import androidx.compose.foundation.layout.Box
2522import androidx.compose.foundation.layout.Column
@@ -32,6 +29,7 @@ import androidx.compose.runtime.DisposableEffect
3229import androidx.compose.runtime.LaunchedEffect
3330import androidx.compose.runtime.derivedStateOf
3431import androidx.compose.runtime.getValue
32+ import androidx.compose.runtime.mutableIntStateOf
3533import androidx.compose.runtime.mutableStateListOf
3634import androidx.compose.runtime.mutableStateOf
3735import androidx.compose.runtime.remember
@@ -68,9 +66,6 @@ import kotlin.time.DurationUnit
6866 * @param modifier the [Modifier] to be applied to this container
6967 * @param config the player configuration to be used when constructing the [THEOplayerView]
7068 * @param source the source description to load into the player
71- * @param interactionSource the [MutableInteractionSource] representing the stream of [Interaction]s
72- * for this container. You can create and pass in your own `remember`ed instance to observe
73- * [Interaction]s and customize the behavior of this container.
7469 * @param color the background color for the overlay while showing the UI controls
7570 * @param centerOverlay content to show in the center of the player, typically a [LoadingSpinner].
7671 * @param errorOverlay content to show when the player encountered a fatal error,
@@ -85,7 +80,6 @@ fun UIController(
8580 modifier : Modifier = Modifier ,
8681 config : THEOplayerConfig ,
8782 source : SourceDescription ? = null,
88- interactionSource : MutableInteractionSource = remember { MutableInteractionSource () },
8983 color : Color = Color .Black ,
9084 centerOverlay : (@Composable UIControllerScope .() -> Unit )? = null,
9185 errorOverlay : (@Composable UIControllerScope .() -> Unit )? = null,
@@ -101,7 +95,6 @@ fun UIController(
10195 UIController (
10296 modifier = modifier,
10397 player = player,
104- interactionSource = interactionSource,
10598 color = color,
10699 centerOverlay = centerOverlay,
107100 errorOverlay = errorOverlay,
@@ -120,9 +113,6 @@ fun UIController(
120113 *
121114 * @param modifier the [Modifier] to be applied to this container
122115 * @param player the player. This should always be created using [rememberPlayer].
123- * @param interactionSource the [MutableInteractionSource] representing the stream of [Interaction]s
124- * for this container. You can create and pass in your own `remember`ed instance to observe
125- * [Interaction]s and customize the behavior of this container.
126116 * @param color the background color for the overlay while showing the UI controls
127117 * @param centerOverlay content to show in the center of the player, typically a [LoadingSpinner].
128118 * @param errorOverlay content to show when the player encountered a fatal error,
@@ -136,15 +126,14 @@ fun UIController(
136126fun UIController (
137127 modifier : Modifier = Modifier ,
138128 player : Player = rememberPlayer(),
139- interactionSource : MutableInteractionSource = remember { MutableInteractionSource () },
140129 color : Color = Color .Black ,
141130 centerOverlay : (@Composable UIControllerScope .() -> Unit )? = null,
142131 errorOverlay : (@Composable UIControllerScope .() -> Unit )? = null,
143132 topChrome : (@Composable UIControllerScope .() -> Unit )? = null,
144133 centerChrome : (@Composable UIControllerScope .() -> Unit )? = null,
145134 bottomChrome : (@Composable UIControllerScope .() -> Unit )? = null
146135) {
147- var tapCount by remember { mutableStateOf (0 ) }
136+ var tapCount by remember { mutableIntStateOf (0 ) }
148137 var isRecentlyTapped by remember { mutableStateOf(false ) }
149138 LaunchedEffect (tapCount) {
150139 if (tapCount > 0 ) {
@@ -153,7 +142,6 @@ fun UIController(
153142 isRecentlyTapped = false
154143 }
155144 }
156- val isPressed by interactionSource.collectIsPressedAsState()
157145 var forceControlsHidden by remember { mutableStateOf(false ) }
158146
159147 // Wait a little bit before showing the controls and enabling animations,
@@ -175,7 +163,7 @@ fun UIController(
175163 } else if (forceControlsHidden) {
176164 false
177165 } else {
178- isRecentlyTapped || isPressed || player.paused
166+ isRecentlyTapped || player.paused
179167 }
180168 }
181169 }
@@ -216,27 +204,29 @@ fun UIController(
216204 )
217205 )
218206
219- PlayerContainer (modifier = modifier, player = player) {
207+ PlayerContainer (
208+ player = player,
209+ modifier = Modifier
210+ .background(Color .Black )
211+ .then(modifier)
212+ .playerAspectRatio(player)
213+ .toggleControlsOnTap(
214+ controlsVisible = controlsVisible,
215+ showControlsTemporarily = {
216+ forceControlsHidden = false
217+ tapCount++
218+ },
219+ hideControls = {
220+ forceControlsHidden = true
221+ tapCount++
222+ }
223+ )
224+ ) {
220225 CompositionLocalProvider (LocalPlayer provides player) {
221- if (player.playingAd) {
222- // Remove player UI entirely while playing an ad, to make clickthrough work
223- return @CompositionLocalProvider
224- }
225226 AnimatedContent (
226227 label = " ContentAnimation" ,
227228 modifier = Modifier
228- .background(background)
229- .pressable(interactionSource = interactionSource, requireUnconsumed = false )
230- .toggleControlsOnTap(
231- controlsVisible = controlsVisible,
232- showControlsTemporarily = {
233- forceControlsHidden = false
234- tapCount++
235- },
236- hideControls = {
237- forceControlsHidden = true
238- tapCount++
239- }),
229+ .background(background),
240230 targetState = uiState,
241231 transitionSpec = {
242232 if (targetState is UIState .Error ) {
@@ -332,13 +322,9 @@ private fun PlayerContainer(
332322 ui : @Composable () -> Unit
333323) {
334324 val theoplayerView = player.theoplayerView
335- val containerModifier = Modifier
336- .background(Color .Black )
337- .then(modifier)
338- .playerAspectRatio(player)
339325 if (theoplayerView == null ) {
340326 Box (
341- modifier = containerModifier
327+ modifier = modifier
342328 ) {
343329 ui()
344330 }
@@ -348,7 +334,7 @@ private fun PlayerContainer(
348334 var composeView by remember { mutableStateOf<ComposeView ?>(null ) }
349335
350336 AndroidView (
351- modifier = containerModifier ,
337+ modifier = modifier ,
352338 factory = { context ->
353339 uiContainer =
354340 theoplayerView.findViewById(com.theoplayer.android.R .id.theo_ui_container)
0 commit comments