播放器UI优化: 上移顶部、缩小胶囊、修复进度条抖动
- 顶部padding从LumaSpacing.md(16dp)减到LumaSpacing.xs(8dp) - 胶囊框padding从16dp/2dp减到12dp/0dp,字体12sp→11sp - 进度条抖动修复:seek完成后延迟300ms重置isSeeking 防止轮询循环在player追上之前覆盖currentPositionMs - 新增seekCompletedVersion计数器触发延迟重置 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
702e9810d0
commit
84d4914d8a
1 file changed
+18
-6
@@ -904,7 +904,7 @@ fun VideoPlayerScreen(
|
||||
}
|
||||
}
|
||||
|
||||
Column(Modifier.fillMaxWidth().statusBarsPadding().padding(top = LumaSpacing.md)) {
|
||||
Column(Modifier.fillMaxWidth().statusBarsPadding().padding(top = LumaSpacing.xs)) {
|
||||
// 第一排:时间(左)| 网速+电量(右)
|
||||
Row(
|
||||
Modifier.fillMaxWidth().padding(horizontal = capsuleInset),
|
||||
@@ -1030,7 +1030,7 @@ fun VideoPlayerScreen(
|
||||
borderColor = Color.White.copy(alpha = 0.22f),
|
||||
shadowElevation = 4.dp,
|
||||
)
|
||||
.padding(horizontal = 16.dp, vertical = 2.dp),
|
||||
.padding(horizontal = 12.dp, vertical = 0.dp),
|
||||
) {
|
||||
var totalDurationMs by remember(player) {
|
||||
mutableLongStateOf(player.duration.coerceAtLeast(0L))
|
||||
@@ -1041,6 +1041,15 @@ fun VideoPlayerScreen(
|
||||
var isSeeking by remember { mutableStateOf(false) }
|
||||
var seekPosition by remember { mutableFloatStateOf(0f) }
|
||||
var bufferProgress by remember { mutableFloatStateOf(0f) }
|
||||
var seekCompletedVersion by remember { mutableIntStateOf(0) }
|
||||
|
||||
// Reset isSeeking after seek completes to prevent jitter
|
||||
LaunchedEffect(seekCompletedVersion) {
|
||||
if (seekCompletedVersion > 0) {
|
||||
delay(300)
|
||||
isSeeking = false
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(player) {
|
||||
while (true) {
|
||||
@@ -1056,9 +1065,9 @@ fun VideoPlayerScreen(
|
||||
}
|
||||
}
|
||||
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(vertical = 2.dp)) {
|
||||
val swipePositionMs = seekPreviewPositionMs
|
||||
Text(formatMs(swipePositionMs ?: currentPositionMs), color = Color.White, fontSize = 12.sp)
|
||||
Text(formatMs(swipePositionMs ?: currentPositionMs), color = Color.White, fontSize = 11.sp)
|
||||
LumaSeekBar(
|
||||
value = when {
|
||||
isSeeking -> seekPosition
|
||||
@@ -1076,10 +1085,13 @@ fun VideoPlayerScreen(
|
||||
player.seekTo(targetPosition)
|
||||
progress = finalValue
|
||||
currentPositionMs = targetPosition
|
||||
isSeeking = false
|
||||
controlsInteractionLocked = false
|
||||
latestOnPlaybackProgress(targetPosition, !player.isPlaying, "TimeUpdate", true)
|
||||
// Keep isSeeking true briefly to prevent polling loop from
|
||||
// overwriting currentPositionMs before player catches up
|
||||
seekCompletedVersion++
|
||||
},
|
||||
modifier = Modifier.weight(1f).padding(horizontal = 12.dp),
|
||||
progressContentDescription = stringResource(Res.string.player_progress),
|
||||
modifier = Modifier.weight(1f).padding(horizontal = 12.dp),
|
||||
activeColor = Color.White,
|
||||
@@ -1088,7 +1100,7 @@ fun VideoPlayerScreen(
|
||||
bufferedValue = bufferProgress,
|
||||
thumbColor = Color.White,
|
||||
)
|
||||
Text(formatMs(totalDurationMs), color = Color.White, fontSize = 12.sp)
|
||||
Text(formatMs(totalDurationMs), color = Color.White, fontSize = 11.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user