From 7eb2e8cd692e8b54568608aae656042c888cc793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Mlynari=C4=8D?= Date: Fri, 26 Apr 2024 21:24:33 +0200 Subject: [PATCH 1/3] Allow Slider seeking player --- .../jetcaster/core/player/EpisodePlayer.kt | 10 +++ .../core/player/MockEpisodePlayer.kt | 11 +++ .../jetcaster/ui/player/PlayerScreen.kt | 70 ++++++++++++++++--- .../jetcaster/ui/player/PlayerViewModel.kt | 8 +++ 4 files changed, 89 insertions(+), 10 deletions(-) diff --git a/Jetcaster/core/src/main/java/com/example/jetcaster/core/player/EpisodePlayer.kt b/Jetcaster/core/src/main/java/com/example/jetcaster/core/player/EpisodePlayer.kt index cbb858a11..9c04f8098 100644 --- a/Jetcaster/core/src/main/java/com/example/jetcaster/core/player/EpisodePlayer.kt +++ b/Jetcaster/core/src/main/java/com/example/jetcaster/core/player/EpisodePlayer.kt @@ -103,6 +103,16 @@ interface EpisodePlayer { */ fun rewindBy(duration: Duration) + /** + * Signal that user started seeking. + */ + fun onSeekingStarted() + + /** + * Seeks to a given time interval specified in [duration]. + */ + fun onSeekingFinished(duration: Duration) + /** * Increases the speed of Player playback by a given time specified in [duration]. */ diff --git a/Jetcaster/core/src/main/java/com/example/jetcaster/core/player/MockEpisodePlayer.kt b/Jetcaster/core/src/main/java/com/example/jetcaster/core/player/MockEpisodePlayer.kt index 4c65a9039..61dcb1e62 100644 --- a/Jetcaster/core/src/main/java/com/example/jetcaster/core/player/MockEpisodePlayer.kt +++ b/Jetcaster/core/src/main/java/com/example/jetcaster/core/player/MockEpisodePlayer.kt @@ -173,6 +173,17 @@ class MockEpisodePlayer( } } + override fun onSeekingStarted() { + // Need to pause the player so that it doesn't compete with timeline progression. + pause() + } + + override fun onSeekingFinished(duration: Duration) { + val currentEpisodeDuration = _currentEpisode.value?.duration ?: return + timeElapsed.update { duration.coerceIn(Duration.ZERO, currentEpisodeDuration) } + play() + } + override fun increaseSpeed(speed: Duration) { _playerSpeed.value += speed } diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index 26904fbe1..fb2d5d4e1 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -67,8 +67,11 @@ import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -130,6 +133,8 @@ fun PlayerScreen( onPausePress = viewModel::onPause, onAdvanceBy = viewModel::onAdvanceBy, onRewindBy = viewModel::onRewindBy, + onSeekingStarted = viewModel::onSeekingStarted, + onSeekingFinished = viewModel::onSeekingFinished, onStop = viewModel::onStop, onNext = viewModel::onNext, onPrevious = viewModel::onPrevious, @@ -150,6 +155,8 @@ private fun PlayerScreen( onPausePress: () -> Unit, onAdvanceBy: (Duration) -> Unit, onRewindBy: (Duration) -> Unit, + onSeekingStarted: () -> Unit, + onSeekingFinished: (Duration) -> Unit, onStop: () -> Unit, onNext: () -> Unit, onPrevious: () -> Unit, @@ -181,6 +188,8 @@ private fun PlayerScreen( onPausePress = onPausePress, onAdvanceBy = onAdvanceBy, onRewindBy = onRewindBy, + onSeekingStarted = onSeekingStarted, + onSeekingFinished = onSeekingFinished, onNext = onNext, onPrevious = onPrevious, onAddToQueue = { @@ -219,6 +228,8 @@ fun PlayerContentWithBackground( onPausePress: () -> Unit, onAdvanceBy: (Duration) -> Unit, onRewindBy: (Duration) -> Unit, + onSeekingStarted: () -> Unit, + onSeekingFinished: (Duration) -> Unit, onNext: () -> Unit, onPrevious: () -> Unit, onAddToQueue: () -> Unit, @@ -238,6 +249,8 @@ fun PlayerContentWithBackground( onPausePress = onPausePress, onAdvanceBy = onAdvanceBy, onRewindBy = onRewindBy, + onSeekingStarted = onSeekingStarted, + onSeekingFinished = onSeekingFinished, onNext = onNext, onPrevious = onPrevious, onAddToQueue = onAddToQueue, @@ -255,6 +268,8 @@ fun PlayerContent( onPausePress: () -> Unit, onAdvanceBy: (Duration) -> Unit, onRewindBy: (Duration) -> Unit, + onSeekingStarted: () -> Unit, + onSeekingFinished: (Duration) -> Unit, onNext: () -> Unit, onPrevious: () -> Unit, onAddToQueue: () -> Unit, @@ -295,6 +310,8 @@ fun PlayerContent( onPausePress = onPausePress, onAdvanceBy = onAdvanceBy, onRewindBy = onRewindBy, + onSeekingStarted = onSeekingStarted, + onSeekingFinished = onSeekingFinished, onNext = onNext, onPrevious = onPrevious, onAddToQueue = onAddToQueue, @@ -331,6 +348,8 @@ fun PlayerContent( onPausePress = onPausePress, onAdvanceBy = onAdvanceBy, onRewindBy = onRewindBy, + onSeekingStarted = onSeekingStarted, + onSeeking = onSeekingFinished, onNext = onNext, onPrevious = onPrevious, ) @@ -348,6 +367,8 @@ fun PlayerContent( onPausePress = onPausePress, onAdvanceBy = onAdvanceBy, onRewindBy = onRewindBy, + onSeekingStarted = onSeekingStarted, + onSeeking = onSeekingFinished, onNext = onNext, onPrevious = onPrevious, onAddToQueue = onAddToQueue, @@ -367,6 +388,8 @@ private fun PlayerContentRegular( onPausePress: () -> Unit, onAdvanceBy: (Duration) -> Unit, onRewindBy: (Duration) -> Unit, + onSeekingStarted: () -> Unit, + onSeeking: (Duration) -> Unit, onNext: () -> Unit, onPrevious: () -> Unit, onAddToQueue: () -> Unit, @@ -407,7 +430,9 @@ private fun PlayerContentRegular( ) { PlayerSlider( timeElapsed = playerEpisode.timeElapsed, - episodeDuration = currentEpisode.duration + episodeDuration = currentEpisode.duration, + onSeekingStarted = onSeekingStarted, + onSeekingFinished = onSeeking ) PlayerButtons( hasNext = playerEpisode.queue.isNotEmpty(), @@ -467,6 +492,8 @@ private fun PlayerContentTableTopBottom( onPausePress: () -> Unit, onAdvanceBy: (Duration) -> Unit, onRewindBy: (Duration) -> Unit, + onSeekingStarted: () -> Unit, + onSeekingFinished: (Duration) -> Unit, onNext: () -> Unit, onPrevious: () -> Unit, onAddToQueue: () -> Unit, @@ -513,7 +540,9 @@ private fun PlayerContentTableTopBottom( ) PlayerSlider( timeElapsed = episodePlayerState.timeElapsed, - episodeDuration = episode.duration + episodeDuration = episode.duration, + onSeekingStarted = onSeekingStarted, + onSeekingFinished = onSeekingFinished ) } } @@ -556,6 +585,8 @@ private fun PlayerContentBookEnd( onPausePress: () -> Unit, onAdvanceBy: (Duration) -> Unit, onRewindBy: (Duration) -> Unit, + onSeekingStarted: () -> Unit, + onSeeking: (Duration) -> Unit, onNext: () -> Unit, onPrevious: () -> Unit, modifier: Modifier = Modifier @@ -577,7 +608,9 @@ private fun PlayerContentBookEnd( ) PlayerSlider( timeElapsed = episodePlayerState.timeElapsed, - episodeDuration = episode.duration + episodeDuration = episode.duration, + onSeekingStarted = onSeekingStarted, + onSeekingFinished = onSeeking, ) PlayerButtons( hasNext = episodePlayerState.queue.isNotEmpty(), @@ -703,21 +736,36 @@ fun Duration.formatString(): String { } @Composable -private fun PlayerSlider(timeElapsed: Duration?, episodeDuration: Duration?) { - Column(Modifier.fillMaxWidth()) { +private fun PlayerSlider( + timeElapsed: Duration, + episodeDuration: Duration?, + onSeekingStarted: () -> Unit, + onSeekingFinished: (newElapsed: Duration) -> Unit, +) { + Column( + Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + ) { + var sliderValue by remember(timeElapsed) { mutableStateOf(timeElapsed) } + val maxRange = (episodeDuration?.toSeconds() ?: 0).toFloat() + Row(Modifier.fillMaxWidth()) { Text( - text = "${timeElapsed?.formatString()} • ${episodeDuration?.formatString()}", + text = "${sliderValue.formatString()} • ${episodeDuration?.formatString()}", style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant ) } - val sliderValue = (timeElapsed?.toSeconds() ?: 0).toFloat() - val maxRange = (episodeDuration?.toSeconds() ?: 0).toFloat() + Slider( - value = sliderValue, + value = sliderValue.seconds.toFloat(), valueRange = 0f..maxRange, - onValueChange = { } + onValueChange = { + onSeekingStarted() + sliderValue = Duration.ofSeconds(it.toLong()) + }, + onValueChangeFinished = { onSeekingFinished(sliderValue) } ) } } @@ -913,6 +961,8 @@ fun PlayerScreenPreview() { onPausePress = {}, onAdvanceBy = {}, onRewindBy = {}, + onSeekingStarted = {}, + onSeekingFinished = {}, onStop = {}, onNext = {}, onPrevious = {}, diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerViewModel.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerViewModel.kt index 9e18c8602..e19861fed 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerViewModel.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerViewModel.kt @@ -100,6 +100,14 @@ class PlayerViewModel @Inject constructor( episodePlayer.rewindBy(duration) } + fun onSeekingStarted() { + episodePlayer.onSeekingStarted() + } + + fun onSeekingFinished(duration: Duration) { + episodePlayer.onSeekingFinished(duration) + } + fun onAddToQueue() { uiState.episodePlayerState.currentEpisode?.let { episodePlayer.addToQueue(it) From c368a4f3067b76ab756115c9db52793691298c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Mlynari=C4=8D?= Date: Fri, 26 Apr 2024 21:56:09 +0200 Subject: [PATCH 2/3] Wraps all control actions into class --- .../jetcaster/ui/player/PlayerScreen.kt | 213 +++++++----------- 1 file changed, 77 insertions(+), 136 deletions(-) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index fb2d5d4e1..8729f1e3a 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -110,8 +110,8 @@ import com.example.jetcaster.util.verticalGradientScrim import com.google.accompanist.adaptive.HorizontalTwoPaneStrategy import com.google.accompanist.adaptive.TwoPane import com.google.accompanist.adaptive.VerticalTwoPaneStrategy -import java.time.Duration import kotlinx.coroutines.launch +import java.time.Duration /** * Stateful version of the Podcast player @@ -129,16 +129,18 @@ fun PlayerScreen( windowSizeClass = windowSizeClass, displayFeatures = displayFeatures, onBackPress = onBackPress, - onPlayPress = viewModel::onPlay, - onPausePress = viewModel::onPause, - onAdvanceBy = viewModel::onAdvanceBy, - onRewindBy = viewModel::onRewindBy, - onSeekingStarted = viewModel::onSeekingStarted, - onSeekingFinished = viewModel::onSeekingFinished, - onStop = viewModel::onStop, - onNext = viewModel::onNext, - onPrevious = viewModel::onPrevious, onAddToQueue = viewModel::onAddToQueue, + onStop = viewModel::onStop, + playerControlActions = PlayerControlActions( + onPlayPress = viewModel::onPlay, + onPausePress = viewModel::onPause, + onAdvanceBy = viewModel::onAdvanceBy, + onRewindBy = viewModel::onRewindBy, + onSeekingStarted = viewModel::onSeekingStarted, + onSeekingFinished = viewModel::onSeekingFinished, + onNext = viewModel::onNext, + onPrevious = viewModel::onPrevious, + ), ) } @@ -151,16 +153,9 @@ private fun PlayerScreen( windowSizeClass: WindowSizeClass, displayFeatures: List, onBackPress: () -> Unit, - onPlayPress: () -> Unit, - onPausePress: () -> Unit, - onAdvanceBy: (Duration) -> Unit, - onRewindBy: (Duration) -> Unit, - onSeekingStarted: () -> Unit, - onSeekingFinished: (Duration) -> Unit, - onStop: () -> Unit, - onNext: () -> Unit, - onPrevious: () -> Unit, onAddToQueue: () -> Unit, + onStop: () -> Unit, + playerControlActions: PlayerControlActions, modifier: Modifier = Modifier ) { DisposableEffect(Unit) { @@ -184,20 +179,13 @@ private fun PlayerScreen( windowSizeClass = windowSizeClass, displayFeatures = displayFeatures, onBackPress = onBackPress, - onPlayPress = onPlayPress, - onPausePress = onPausePress, - onAdvanceBy = onAdvanceBy, - onRewindBy = onRewindBy, - onSeekingStarted = onSeekingStarted, - onSeekingFinished = onSeekingFinished, - onNext = onNext, - onPrevious = onPrevious, onAddToQueue = { coroutineScope.launch { snackbarHostState.showSnackbar(snackBarText) } onAddToQueue() }, + playerControlActions = playerControlActions, modifier = Modifier.padding(contentPadding) ) } else { @@ -224,15 +212,8 @@ fun PlayerContentWithBackground( windowSizeClass: WindowSizeClass, displayFeatures: List, onBackPress: () -> Unit, - onPlayPress: () -> Unit, - onPausePress: () -> Unit, - onAdvanceBy: (Duration) -> Unit, - onRewindBy: (Duration) -> Unit, - onSeekingStarted: () -> Unit, - onSeekingFinished: (Duration) -> Unit, - onNext: () -> Unit, - onPrevious: () -> Unit, onAddToQueue: () -> Unit, + playerControlActions: PlayerControlActions, modifier: Modifier = Modifier ) { Box(modifier = modifier, contentAlignment = Alignment.Center) { @@ -245,34 +226,34 @@ fun PlayerContentWithBackground( windowSizeClass = windowSizeClass, displayFeatures = displayFeatures, onBackPress = onBackPress, - onPlayPress = onPlayPress, - onPausePress = onPausePress, - onAdvanceBy = onAdvanceBy, - onRewindBy = onRewindBy, - onSeekingStarted = onSeekingStarted, - onSeekingFinished = onSeekingFinished, - onNext = onNext, - onPrevious = onPrevious, onAddToQueue = onAddToQueue, + playerControlActions = playerControlActions, ) } } +/** + * Wrapper around all actions for the player controls. + */ +data class PlayerControlActions( + val onPlayPress: () -> Unit, + val onPausePress: () -> Unit, + val onAdvanceBy: (Duration) -> Unit, + val onRewindBy: (Duration) -> Unit, + val onNext: () -> Unit, + val onPrevious: () -> Unit, + val onSeekingStarted: () -> Unit, + val onSeekingFinished: (newElapsed: Duration) -> Unit, +) + @Composable fun PlayerContent( uiState: PlayerUiState, windowSizeClass: WindowSizeClass, displayFeatures: List, onBackPress: () -> Unit, - onPlayPress: () -> Unit, - onPausePress: () -> Unit, - onAdvanceBy: (Duration) -> Unit, - onRewindBy: (Duration) -> Unit, - onSeekingStarted: () -> Unit, - onSeekingFinished: (Duration) -> Unit, - onNext: () -> Unit, - onPrevious: () -> Unit, onAddToQueue: () -> Unit, + playerControlActions: PlayerControlActions, modifier: Modifier = Modifier ) { val foldingFeature = displayFeatures.filterIsInstance().firstOrNull() @@ -290,10 +271,10 @@ fun PlayerContent( // or we have an impactful horizontal fold. Otherwise, we'll use a horizontal strategy. val usingVerticalStrategy = isTableTopPosture(foldingFeature) || - ( - isSeparatingPosture(foldingFeature) && - foldingFeature.orientation == FoldingFeature.Orientation.HORIZONTAL - ) + ( + isSeparatingPosture(foldingFeature) && + foldingFeature.orientation == FoldingFeature.Orientation.HORIZONTAL + ) if (usingVerticalStrategy) { TwoPane( @@ -306,15 +287,8 @@ fun PlayerContent( PlayerContentTableTopBottom( uiState = uiState, onBackPress = onBackPress, - onPlayPress = onPlayPress, - onPausePress = onPausePress, - onAdvanceBy = onAdvanceBy, - onRewindBy = onRewindBy, - onSeekingStarted = onSeekingStarted, - onSeekingFinished = onSeekingFinished, - onNext = onNext, - onPrevious = onPrevious, onAddToQueue = onAddToQueue, + playerControlActions = playerControlActions, ) }, strategy = VerticalTwoPaneStrategy(splitFraction = 0.5f), @@ -344,14 +318,7 @@ fun PlayerContent( second = { PlayerContentBookEnd( uiState = uiState, - onPlayPress = onPlayPress, - onPausePress = onPausePress, - onAdvanceBy = onAdvanceBy, - onRewindBy = onRewindBy, - onSeekingStarted = onSeekingStarted, - onSeeking = onSeekingFinished, - onNext = onNext, - onPrevious = onPrevious, + playerControlActions = playerControlActions, ) }, strategy = HorizontalTwoPaneStrategy(splitFraction = 0.5f), @@ -363,15 +330,8 @@ fun PlayerContent( PlayerContentRegular( uiState = uiState, onBackPress = onBackPress, - onPlayPress = onPlayPress, - onPausePress = onPausePress, - onAdvanceBy = onAdvanceBy, - onRewindBy = onRewindBy, - onSeekingStarted = onSeekingStarted, - onSeeking = onSeekingFinished, - onNext = onNext, - onPrevious = onPrevious, onAddToQueue = onAddToQueue, + playerControlActions = playerControlActions, modifier = modifier, ) } @@ -384,15 +344,8 @@ fun PlayerContent( private fun PlayerContentRegular( uiState: PlayerUiState, onBackPress: () -> Unit, - onPlayPress: () -> Unit, - onPausePress: () -> Unit, - onAdvanceBy: (Duration) -> Unit, - onRewindBy: (Duration) -> Unit, - onSeekingStarted: () -> Unit, - onSeeking: (Duration) -> Unit, - onNext: () -> Unit, - onPrevious: () -> Unit, onAddToQueue: () -> Unit, + playerControlActions: PlayerControlActions, modifier: Modifier = Modifier ) { val playerEpisode = uiState.episodePlayerState @@ -431,18 +384,18 @@ private fun PlayerContentRegular( PlayerSlider( timeElapsed = playerEpisode.timeElapsed, episodeDuration = currentEpisode.duration, - onSeekingStarted = onSeekingStarted, - onSeekingFinished = onSeeking + onSeekingStarted = playerControlActions.onSeekingStarted, + onSeekingFinished = playerControlActions.onSeekingFinished ) PlayerButtons( hasNext = playerEpisode.queue.isNotEmpty(), isPlaying = playerEpisode.isPlaying, - onPlayPress = onPlayPress, - onPausePress = onPausePress, - onAdvanceBy = onAdvanceBy, - onRewindBy = onRewindBy, - onNext = onNext, - onPrevious = onPrevious, + onPlayPress = playerControlActions.onPlayPress, + onPausePress = playerControlActions.onPausePress, + onAdvanceBy = playerControlActions.onAdvanceBy, + onRewindBy = playerControlActions.onRewindBy, + onNext = playerControlActions.onNext, + onPrevious = playerControlActions.onPrevious, Modifier.padding(vertical = 8.dp) ) } @@ -488,15 +441,8 @@ private fun PlayerContentTableTopTop( private fun PlayerContentTableTopBottom( uiState: PlayerUiState, onBackPress: () -> Unit, - onPlayPress: () -> Unit, - onPausePress: () -> Unit, - onAdvanceBy: (Duration) -> Unit, - onRewindBy: (Duration) -> Unit, - onSeekingStarted: () -> Unit, - onSeekingFinished: (Duration) -> Unit, - onNext: () -> Unit, - onPrevious: () -> Unit, onAddToQueue: () -> Unit, + playerControlActions: PlayerControlActions, modifier: Modifier = Modifier ) { val episodePlayerState = uiState.episodePlayerState @@ -529,20 +475,20 @@ private fun PlayerContentTableTopBottom( PlayerButtons( hasNext = episodePlayerState.queue.isNotEmpty(), isPlaying = episodePlayerState.isPlaying, - onPlayPress = onPlayPress, - onPausePress = onPausePress, + onPlayPress = playerControlActions.onPlayPress, + onPausePress = playerControlActions.onPausePress, playerButtonSize = 92.dp, - onAdvanceBy = onAdvanceBy, - onRewindBy = onRewindBy, - onNext = onNext, - onPrevious = onPrevious, + onAdvanceBy = playerControlActions.onAdvanceBy, + onRewindBy = playerControlActions.onRewindBy, + onNext = playerControlActions.onNext, + onPrevious = playerControlActions.onPrevious, modifier = Modifier.padding(top = 8.dp) ) PlayerSlider( timeElapsed = episodePlayerState.timeElapsed, episodeDuration = episode.duration, - onSeekingStarted = onSeekingStarted, - onSeekingFinished = onSeekingFinished + onSeekingStarted = playerControlActions.onSeekingStarted, + onSeekingFinished = playerControlActions.onSeekingFinished ) } } @@ -581,14 +527,7 @@ private fun PlayerContentBookStart( @Composable private fun PlayerContentBookEnd( uiState: PlayerUiState, - onPlayPress: () -> Unit, - onPausePress: () -> Unit, - onAdvanceBy: (Duration) -> Unit, - onRewindBy: (Duration) -> Unit, - onSeekingStarted: () -> Unit, - onSeeking: (Duration) -> Unit, - onNext: () -> Unit, - onPrevious: () -> Unit, + playerControlActions: PlayerControlActions, modifier: Modifier = Modifier ) { val episodePlayerState = uiState.episodePlayerState @@ -609,18 +548,18 @@ private fun PlayerContentBookEnd( PlayerSlider( timeElapsed = episodePlayerState.timeElapsed, episodeDuration = episode.duration, - onSeekingStarted = onSeekingStarted, - onSeekingFinished = onSeeking, + onSeekingStarted = playerControlActions.onSeekingStarted, + onSeekingFinished = playerControlActions.onSeekingFinished, ) PlayerButtons( hasNext = episodePlayerState.queue.isNotEmpty(), isPlaying = episodePlayerState.isPlaying, - onPlayPress = onPlayPress, - onPausePress = onPausePress, - onAdvanceBy = onAdvanceBy, - onRewindBy = onRewindBy, - onNext = onNext, - onPrevious = onPrevious, + onPlayPress = playerControlActions.onPlayPress, + onPausePress = playerControlActions.onPausePress, + onAdvanceBy = playerControlActions.onAdvanceBy, + onRewindBy = playerControlActions.onRewindBy, + onNext = playerControlActions.onNext, + onPrevious = playerControlActions.onPrevious, Modifier.padding(vertical = 8.dp) ) } @@ -957,16 +896,18 @@ fun PlayerScreenPreview() { displayFeatures = emptyList(), windowSizeClass = WindowSizeClass.compute(maxWidth.value, maxHeight.value), onBackPress = { }, - onPlayPress = {}, - onPausePress = {}, - onAdvanceBy = {}, - onRewindBy = {}, - onSeekingStarted = {}, - onSeekingFinished = {}, - onStop = {}, - onNext = {}, - onPrevious = {}, onAddToQueue = {}, + onStop = {}, + playerControlActions = PlayerControlActions( + onPlayPress = {}, + onPausePress = {}, + onAdvanceBy = {}, + onRewindBy = {}, + onSeekingStarted = {}, + onSeekingFinished = {}, + onNext = {}, + onPrevious = {}, + ) ) } } From bd334fafa98cce391ac04c8a06fca28b5c29296c Mon Sep 17 00:00:00 2001 From: mlykotom Date: Fri, 26 Apr 2024 19:58:37 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A4=96=20Apply=20Spotless?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/jetcaster/ui/player/PlayerScreen.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt index 8729f1e3a..80a78494d 100644 --- a/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt +++ b/Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/player/PlayerScreen.kt @@ -110,8 +110,8 @@ import com.example.jetcaster.util.verticalGradientScrim import com.google.accompanist.adaptive.HorizontalTwoPaneStrategy import com.google.accompanist.adaptive.TwoPane import com.google.accompanist.adaptive.VerticalTwoPaneStrategy -import kotlinx.coroutines.launch import java.time.Duration +import kotlinx.coroutines.launch /** * Stateful version of the Podcast player @@ -271,10 +271,10 @@ fun PlayerContent( // or we have an impactful horizontal fold. Otherwise, we'll use a horizontal strategy. val usingVerticalStrategy = isTableTopPosture(foldingFeature) || - ( - isSeparatingPosture(foldingFeature) && - foldingFeature.orientation == FoldingFeature.Orientation.HORIZONTAL - ) + ( + isSeparatingPosture(foldingFeature) && + foldingFeature.orientation == FoldingFeature.Orientation.HORIZONTAL + ) if (usingVerticalStrategy) { TwoPane(