From 19ae4a34d53b7a461ed8dd9a7f1dc6e8ed1805b8 Mon Sep 17 00:00:00 2001 From: acite <1498045907@qq.com> Date: Mon, 25 Aug 2025 14:26:13 +0800 Subject: [PATCH] [fix] Fix tablet full-screen mode bug --- README.md | 2 +- .../com/acitelight/aether/view/VideoPlayer.kt | 333 +++++++++--------- 2 files changed, 169 insertions(+), 166 deletions(-) diff --git a/README.md b/README.md index 03f8ef4..b7308d6 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ _🚀This is the client of the multimedia server Abyss, which can also be extend ## TODO List ### High Priority -- [ ] Fix tablet full-screen mode bug +- [x] Fix tablet full-screen mode bug - [ ] Hide private key after user input - [ ] Replace Android robot icon with custom design - [ ] Configure server baseURL in client settings diff --git a/app/src/main/java/com/acitelight/aether/view/VideoPlayer.kt b/app/src/main/java/com/acitelight/aether/view/VideoPlayer.kt index a6fed4d..3f2f895 100644 --- a/app/src/main/java/com/acitelight/aether/view/VideoPlayer.kt +++ b/app/src/main/java/com/acitelight/aether/view/VideoPlayer.kt @@ -716,153 +716,78 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel) } ToggleFullScreen(true) - Box( - modifier = Modifier - .background(Color.Black) - ) + Box(Modifier.fillMaxSize()) { - AndroidView( - factory = { - PlayerView( - it - ).apply { - player = exoPlayer - useController = false - } - }, + Box( modifier = Modifier - .fillMaxWidth() - .pointerInput(Unit) { - detectDragGestures( - onDragStart = { - videoPlayerViewModel.planeVisibility = true - videoPlayerViewModel.dragging = true; - exoPlayer.pause() - }, - onDragEnd = { - videoPlayerViewModel.dragging = false; - if (videoPlayerViewModel.isPlaying) - exoPlayer.play() - }, - onDrag = { change, dragAmount -> - exoPlayer.seekTo((exoPlayer.currentPosition + dragAmount.x * 200.0f).toLong()) - videoPlayerViewModel.playProcess = exoPlayer.currentPosition.toFloat() / exoPlayer.duration.toFloat() - } - ) - } - .pointerInput(Unit) { - detectTapGestures( - onDoubleTap = { - videoPlayerViewModel.isPlaying = !videoPlayerViewModel.isPlaying - if (videoPlayerViewModel.isPlaying) exoPlayer.play() else exoPlayer.pause() - }, - onTap = { - videoPlayerViewModel.planeVisibility = - !videoPlayerViewModel.planeVisibility - }, - onLongPress = { - videoPlayerViewModel.isLongPressing = true - exoPlayer.playbackParameters = exoPlayer.playbackParameters - .withSpeed(3.0f) - }, - onPress = { offset -> - val pressResult = tryAwaitRelease() - if (pressResult && videoPlayerViewModel.isLongPressing) { - videoPlayerViewModel.isLongPressing = false - exoPlayer.playbackParameters = exoPlayer.playbackParameters - .withSpeed(1.0f) - } - }, - ) - } - ) - - androidx.compose.animation.AnimatedVisibility( - visible = videoPlayerViewModel.dragging, - enter = fadeIn( - initialAlpha = 0f, - ), - exit = fadeOut( - targetAlpha = 0f - ), - modifier = Modifier.align(Alignment.Center) - ) { - Text( - text = "${formatTime((exoPlayer.duration * videoPlayerViewModel.playProcess).toLong())}/${ - formatTime( - (exoPlayer.duration).toLong() - ) - }", - fontWeight = FontWeight.Bold, - modifier = Modifier.padding(bottom = 12.dp), - fontSize = 18.sp - ) - } - - AnimatedVisibility( - visible = videoPlayerViewModel.isLongPressing, - enter = slideInVertically(initialOffsetY = { fullHeight -> -fullHeight }), - exit = slideOutVertically(targetOffsetY = { fullHeight -> -fullHeight }), - modifier = Modifier - .align(Alignment.TopCenter) + .background(Color.Black).align(Alignment.Center) ) { - Box(modifier = Modifier.align(Alignment.TopCenter).padding(top = 24.dp).background(Color(0x44000000), RoundedCornerShape(18))) - { - Row{ - Icon( - imageVector = Icons.Filled.FastForward, - contentDescription = "Fast Forward", - tint = Color.White, - modifier = Modifier.size(36.dp).padding(4.dp).align(Alignment.CenterVertically) - ) - - Text( - text = "3X Speed...", - modifier = Modifier.padding(4.dp).align(Alignment.CenterVertically), - fontSize = 16.sp, - fontWeight = FontWeight.Bold, - color = Color(0xFFFFFFFF) - ) - } - } - } - - IconButton( - onClick = { - activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT - }, - modifier = Modifier - .align(Alignment.TopStart) - .padding(8.dp) - ) { - Icon( - imageVector = Icons.AutoMirrored.Filled.ArrowBack, - contentDescription = "Back", - tint = Color.White - ) - } - - AnimatedVisibility( - visible = videoPlayerViewModel.planeVisibility, - enter = slideInVertically(initialOffsetY = { fullHeight -> fullHeight }), - exit = slideOutVertically(targetOffsetY = { fullHeight -> fullHeight }), - modifier = Modifier - .align(Alignment.BottomCenter) - .fillMaxWidth() - ) - { - Column( + AndroidView( + factory = { + PlayerView( + it + ).apply { + player = exoPlayer + useController = false + } + }, modifier = Modifier - .align(Alignment.BottomCenter) .fillMaxWidth() - .background( brush = Brush.verticalGradient( - colors = listOf( - Color.Transparent, - Color.Black.copy(alpha = 0.4f) + .pointerInput(Unit) { + detectDragGestures( + onDragStart = { + videoPlayerViewModel.planeVisibility = true + videoPlayerViewModel.dragging = true; + exoPlayer.pause() + }, + onDragEnd = { + videoPlayerViewModel.dragging = false; + if (videoPlayerViewModel.isPlaying) + exoPlayer.play() + }, + onDrag = { change, dragAmount -> + exoPlayer.seekTo((exoPlayer.currentPosition + dragAmount.x * 200.0f).toLong()) + videoPlayerViewModel.playProcess = exoPlayer.currentPosition.toFloat() / exoPlayer.duration.toFloat() + } ) - )) - .padding(horizontal = 36.dp) + } + .pointerInput(Unit) { + detectTapGestures( + onDoubleTap = { + videoPlayerViewModel.isPlaying = !videoPlayerViewModel.isPlaying + if (videoPlayerViewModel.isPlaying) exoPlayer.play() else exoPlayer.pause() + }, + onTap = { + videoPlayerViewModel.planeVisibility = + !videoPlayerViewModel.planeVisibility + }, + onLongPress = { + videoPlayerViewModel.isLongPressing = true + exoPlayer.playbackParameters = exoPlayer.playbackParameters + .withSpeed(3.0f) + }, + onPress = { offset -> + val pressResult = tryAwaitRelease() + if (pressResult && videoPlayerViewModel.isLongPressing) { + videoPlayerViewModel.isLongPressing = false + exoPlayer.playbackParameters = exoPlayer.playbackParameters + .withSpeed(1.0f) + } + }, + ) + } + ) + + androidx.compose.animation.AnimatedVisibility( + visible = videoPlayerViewModel.dragging, + enter = fadeIn( + initialAlpha = 0f, + ), + exit = fadeOut( + targetAlpha = 0f + ), + modifier = Modifier.align(Alignment.Center) ) { Text( text = "${formatTime((exoPlayer.duration * videoPlayerViewModel.playProcess).toLong())}/${ @@ -872,35 +797,113 @@ fun VideoPlayerLandscape(videoPlayerViewModel: VideoPlayerViewModel) }", fontWeight = FontWeight.Bold, modifier = Modifier.padding(bottom = 12.dp), - fontSize = 12.sp + fontSize = 18.sp ) - BiliStyleSlider( - value = videoPlayerViewModel.playProcess, - onValueChange = { value -> - exoPlayer.seekTo((exoPlayer.duration * value).toLong()) - }, - modifier = Modifier.height(16.dp).fillMaxWidth().padding(bottom = 8.dp) - ) - Row( - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 8.dp) - .align(Alignment.Start), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - IconButton( - onClick = { - videoPlayerViewModel.isPlaying = !videoPlayerViewModel.isPlaying - if (videoPlayerViewModel.isPlaying) exoPlayer.play() else exoPlayer.pause() - }, - Modifier.size(42.dp) - ) { + } + + AnimatedVisibility( + visible = videoPlayerViewModel.isLongPressing, + enter = slideInVertically(initialOffsetY = { fullHeight -> -fullHeight }), + exit = slideOutVertically(targetOffsetY = { fullHeight -> -fullHeight }), + modifier = Modifier + .align(Alignment.TopCenter) + ) + { + Box(modifier = Modifier.align(Alignment.TopCenter).padding(top = 24.dp).background(Color(0x44000000), RoundedCornerShape(18))) + { + Row{ Icon( - imageVector = if (videoPlayerViewModel.isPlaying) Icons.Default.Pause else Icons.Default.PlayArrow, - contentDescription = "Play/Pause", + imageVector = Icons.Filled.FastForward, + contentDescription = "Fast Forward", tint = Color.White, - modifier = Modifier.size(42.dp) + modifier = Modifier.size(36.dp).padding(4.dp).align(Alignment.CenterVertically) ) + + Text( + text = "3X Speed...", + modifier = Modifier.padding(4.dp).align(Alignment.CenterVertically), + fontSize = 16.sp, + fontWeight = FontWeight.Bold, + color = Color(0xFFFFFFFF) + ) + } + } + } + + IconButton( + onClick = { + activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + }, + modifier = Modifier + .align(Alignment.TopStart) + .padding(8.dp) + ) { + Icon( + imageVector = Icons.AutoMirrored.Filled.ArrowBack, + contentDescription = "Back", + tint = Color.White + ) + } + + AnimatedVisibility( + visible = videoPlayerViewModel.planeVisibility, + enter = slideInVertically(initialOffsetY = { fullHeight -> fullHeight }), + exit = slideOutVertically(targetOffsetY = { fullHeight -> fullHeight }), + modifier = Modifier + .align(Alignment.BottomCenter) + .fillMaxWidth() + ) + { + Column( + modifier = Modifier + .align(Alignment.BottomCenter) + .fillMaxWidth() + .background( brush = Brush.verticalGradient( + colors = listOf( + Color.Transparent, + Color.Black.copy(alpha = 0.4f) + ) + )) + .padding(horizontal = 36.dp) + ) { + Text( + text = "${formatTime((exoPlayer.duration * videoPlayerViewModel.playProcess).toLong())}/${ + formatTime( + (exoPlayer.duration).toLong() + ) + }", + fontWeight = FontWeight.Bold, + modifier = Modifier.padding(bottom = 12.dp), + fontSize = 12.sp + ) + BiliStyleSlider( + value = videoPlayerViewModel.playProcess, + onValueChange = { value -> + exoPlayer.seekTo((exoPlayer.duration * value).toLong()) + }, + modifier = Modifier.height(16.dp).fillMaxWidth().padding(bottom = 8.dp) + ) + Row( + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 8.dp) + .align(Alignment.Start), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + IconButton( + onClick = { + videoPlayerViewModel.isPlaying = !videoPlayerViewModel.isPlaying + if (videoPlayerViewModel.isPlaying) exoPlayer.play() else exoPlayer.pause() + }, + Modifier.size(42.dp) + ) { + Icon( + imageVector = if (videoPlayerViewModel.isPlaying) Icons.Default.Pause else Icons.Default.PlayArrow, + contentDescription = "Play/Pause", + tint = Color.White, + modifier = Modifier.size(42.dp) + ) + } } } }