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