Code review fixes:
skipSeconds duplication + stale duration read pointerInput(Unit) stale capture ShareMediaAction composed unconditionally Overflow menu background opaque in dark theme
This commit is contained in:
+4
-2
@@ -48,6 +48,8 @@ import com.vitorpamplona.amethyst.service.playback.composable.wavefront.Waveform
|
|||||||
import com.vitorpamplona.amethyst.service.playback.diskCache.isLiveStreaming
|
import com.vitorpamplona.amethyst.service.playback.diskCache.isLiveStreaming
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
|
|
||||||
|
internal fun computeSkipSeconds(durationMs: Long): Int = if (durationMs in 1..30000) 5 else 10
|
||||||
|
|
||||||
private fun getVideoSizeDp(player: Player): Size? {
|
private fun getVideoSizeDp(player: Player): Size? {
|
||||||
var videoSize = Size(player.videoSize.width.toFloat(), player.videoSize.height.toFloat())
|
var videoSize = Size(player.videoSize.width.toFloat(), player.videoSize.height.toFloat())
|
||||||
|
|
||||||
@@ -78,17 +80,17 @@ fun RenderVideoPlayer(
|
|||||||
) {
|
) {
|
||||||
val containerSize = remember { mutableStateOf(IntSize.Zero) }
|
val containerSize = remember { mutableStateOf(IntSize.Zero) }
|
||||||
val isLive = isLiveStreaming(mediaItem.src.videoUri)
|
val isLive = isLiveStreaming(mediaItem.src.videoUri)
|
||||||
val skipSeconds = if (controllerState.controller.duration in 1..30000) 5 else 10
|
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier =
|
modifier =
|
||||||
borderModifier
|
borderModifier
|
||||||
.onSizeChanged { containerSize.value = it }
|
.onSizeChanged { containerSize.value = it }
|
||||||
.pointerInput(Unit) {
|
.pointerInput(isLive, controllerState) {
|
||||||
detectTapGestures(
|
detectTapGestures(
|
||||||
onTap = { controllerVisible.value = !controllerVisible.value },
|
onTap = { controllerVisible.value = !controllerVisible.value },
|
||||||
onDoubleTap = { offset ->
|
onDoubleTap = { offset ->
|
||||||
if (!isLive) {
|
if (!isLive) {
|
||||||
|
val skipSeconds = computeSkipSeconds(controllerState.controller.duration)
|
||||||
val isLeftSide = offset.x < containerSize.value.width / 2
|
val isLeftSide = offset.x < containerSize.value.width / 2
|
||||||
if (isLeftSide) {
|
if (isLeftSide) {
|
||||||
val newPosition =
|
val newPosition =
|
||||||
|
|||||||
+1
-1
@@ -117,7 +117,7 @@ fun OverflowMenuButton(
|
|||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.fillMaxSize(0.7f)
|
.fillMaxSize(0.7f)
|
||||||
.align(Alignment.Center)
|
.align(Alignment.Center)
|
||||||
.background(MaterialTheme.colorScheme.background),
|
.background(Color.Black.copy(alpha = 0.4f)),
|
||||||
)
|
)
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|||||||
+2
-1
@@ -32,6 +32,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.media3.common.util.UnstableApi
|
import androidx.media3.common.util.UnstableApi
|
||||||
import androidx.media3.ui.compose.state.rememberPlayPauseButtonState
|
import androidx.media3.ui.compose.state.rememberPlayPauseButtonState
|
||||||
import com.vitorpamplona.amethyst.service.playback.composable.MediaControllerState
|
import com.vitorpamplona.amethyst.service.playback.composable.MediaControllerState
|
||||||
|
import com.vitorpamplona.amethyst.service.playback.composable.computeSkipSeconds
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
@@ -44,7 +45,7 @@ fun RenderCenterButtons(
|
|||||||
videoDurationMs: Long = 0L,
|
videoDurationMs: Long = 0L,
|
||||||
) {
|
) {
|
||||||
val state = rememberPlayPauseButtonState(controllerState.controller)
|
val state = rememberPlayPauseButtonState(controllerState.controller)
|
||||||
val skipSeconds = if (videoDurationMs in 1..30000) 5 else 10
|
val skipSeconds = computeSkipSeconds(videoDurationMs)
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
|
|||||||
+23
-26
@@ -21,7 +21,6 @@
|
|||||||
package com.vitorpamplona.amethyst.service.playback.composable.controls
|
package com.vitorpamplona.amethyst.service.playback.composable.controls
|
||||||
|
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@@ -79,11 +78,7 @@ fun RenderTopButtons(
|
|||||||
val isLive = isLiveStreaming(mediaData.videoUri)
|
val isLive = isLiveStreaming(mediaData.videoUri)
|
||||||
val pipSupported =
|
val pipSupported =
|
||||||
remember {
|
remember {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
context.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)
|
||||||
context.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderTopButtons(
|
RenderTopButtons(
|
||||||
@@ -155,24 +150,26 @@ fun RenderTopButtons(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
ShareMediaAction(
|
if (shareDialogVisible.value) {
|
||||||
popupExpanded = shareDialogVisible,
|
ShareMediaAction(
|
||||||
videoUri = mediaData.videoUri,
|
popupExpanded = shareDialogVisible,
|
||||||
postNostrUri = mediaData.callbackUri,
|
videoUri = mediaData.videoUri,
|
||||||
blurhash = null,
|
postNostrUri = mediaData.callbackUri,
|
||||||
dim = null,
|
blurhash = null,
|
||||||
hash = null,
|
dim = null,
|
||||||
mimeType = mediaData.mimeType,
|
hash = null,
|
||||||
onDismiss = { shareDialogVisible.value = false },
|
mimeType = mediaData.mimeType,
|
||||||
content =
|
onDismiss = { shareDialogVisible.value = false },
|
||||||
MediaUrlVideo(
|
content =
|
||||||
url = mediaData.videoUri,
|
MediaUrlVideo(
|
||||||
mimeType = mediaData.mimeType,
|
url = mediaData.videoUri,
|
||||||
artworkUri = mediaData.artworkUri,
|
mimeType = mediaData.mimeType,
|
||||||
authorName = mediaData.authorName,
|
artworkUri = mediaData.artworkUri,
|
||||||
description = mediaData.title,
|
authorName = mediaData.authorName,
|
||||||
uri = mediaData.callbackUri,
|
description = mediaData.title,
|
||||||
),
|
uri = mediaData.callbackUri,
|
||||||
accountViewModel = accountViewModel,
|
),
|
||||||
)
|
accountViewModel = accountViewModel,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user