From 042b69cc05bafa1472846cfce112a61deb0d5c84 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Mon, 13 Jan 2025 10:56:14 +0800 Subject: [PATCH] opt: viewpoint Signed-off-by: bggRGjQaUbCoE --- lib/common/widgets/segment_progress_bar.dart | 2 + lib/pages/video/detail/controller.dart | 19 +-- lib/plugin/pl_player/view.dart | 32 ++-- .../pl_player/widgets/bottom_control.dart | 142 ++++++++++-------- 4 files changed, 113 insertions(+), 82 deletions(-) diff --git a/lib/common/widgets/segment_progress_bar.dart b/lib/common/widgets/segment_progress_bar.dart index e56d9747..67a5085e 100644 --- a/lib/common/widgets/segment_progress_bar.dart +++ b/lib/common/widgets/segment_progress_bar.dart @@ -48,8 +48,10 @@ class SegmentProgressBar extends CustomPainter { style: TextStyle( color: Colors.white, fontSize: fontSize, + height: 1, ), ), + strutStyle: StrutStyle(height: 1, leading: 0), textDirection: TextDirection.ltr, )..layout(); diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 6b246b3e..c9a10dcd 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -1992,15 +1992,6 @@ class VideoDetailController extends GetxController } catch (_) {} } - if (res["data"] is List && res["data"].isNotEmpty) { - var result = await VideoHttp.vttSubtitles(res["data"]); - if (result != null) { - _vttSubtitles = result; - } - // if (_vttSubtitles.isEmpty) { - // SmartDialog.showToast('字幕均加载失败'); - // } - } if (GStorage.showViewPoints && res["view_points"] is List && res["view_points"].isNotEmpty) { @@ -2022,6 +2013,16 @@ class VideoDetailController extends GetxController plPlayerController.showVP.value = showVP = true; } } + + if (res["data"] is List && res["data"].isNotEmpty) { + var result = await VideoHttp.vttSubtitles(res["data"]); + if (result != null) { + _vttSubtitles = result; + } + // if (_vttSubtitles.isEmpty) { + // SmartDialog.showToast('字幕均加载失败'); + // } + } } } diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 7e922a9a..e5fcc6b6 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -1050,7 +1050,7 @@ class _PLVideoPlayerState extends State value: '${(value / max * 100).round()}%', // enabled: false, child: Stack( - alignment: Alignment.center, + alignment: Alignment.bottomCenter, children: [ ProgressBar( progress: Duration(seconds: value), @@ -1097,18 +1097,32 @@ class _PLVideoPlayerState extends State // }, ), if (plPlayerController.segmentList.isNotEmpty) - CustomPaint( - size: Size(double.infinity, 3.5), - painter: SegmentProgressBar( - segmentColors: plPlayerController.segmentList, + Positioned( + left: 0, + right: 0, + bottom: 0.75, + child: IgnorePointer( + child: CustomPaint( + size: Size(double.infinity, 3.5), + painter: SegmentProgressBar( + segmentColors: plPlayerController.segmentList, + ), + ), ), ), if (plPlayerController.viewPointList.isNotEmpty && plPlayerController.showVP.value) - CustomPaint( - size: Size(double.infinity, 3.5), - painter: SegmentProgressBar( - segmentColors: plPlayerController.viewPointList, + Positioned( + left: 0, + right: 0, + bottom: 0.75, + child: IgnorePointer( + child: CustomPaint( + size: Size(double.infinity, 3.5), + painter: SegmentProgressBar( + segmentColors: plPlayerController.viewPointList, + ), + ), ), ), ], diff --git a/lib/plugin/pl_player/widgets/bottom_control.dart b/lib/plugin/pl_player/widgets/bottom_control.dart index 73a78291..2c40460c 100644 --- a/lib/plugin/pl_player/widgets/bottom_control.dart +++ b/lib/plugin/pl_player/widgets/bottom_control.dart @@ -46,73 +46,87 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { return Padding( padding: const EdgeInsets.only(left: 10, right: 10, bottom: 7), child: Semantics( - // label: '${(value / max * 100).round()}%', - value: '${(value / max * 100).round()}%', - // enabled: false, - child: Stack( - alignment: Alignment.center, - children: [ - ProgressBar( - progress: Duration(seconds: value), - buffered: Duration(seconds: buffer), - total: Duration(seconds: max), - progressBarColor: colorTheme, - baseBarColor: Colors.white.withOpacity(0.2), - bufferedBarColor: colorTheme.withOpacity(0.4), - timeLabelLocation: TimeLabelLocation.none, - thumbColor: colorTheme, - barHeight: 3.5, - thumbRadius: 7, - onDragStart: (duration) { - feedBack(); - controller!.onChangedSliderStart(); - }, - onDragUpdate: (duration) { - double newProgress = - duration.timeStamp.inSeconds / max; - if ((newProgress - lastAnnouncedValue).abs() > - 0.02) { - accessibilityDebounce?.cancel(); - accessibilityDebounce = - Timer(const Duration(milliseconds: 200), () { - SemanticsService.announce( - "${(newProgress * 100).round()}%", - TextDirection.ltr); - lastAnnouncedValue = newProgress; - }); - } - controller! - .onUpdatedSliderProgress(duration.timeStamp); - }, - onSeek: (duration) { - controller!.onChangedSliderEnd(); - controller! - .onChangedSlider(duration.inSeconds.toDouble()); - controller!.seekTo( - Duration(seconds: duration.inSeconds), - type: 'slider'); - SemanticsService.announce( - "${(duration.inSeconds / max * 100).round()}%", - TextDirection.ltr); - }, + // label: '${(value / max * 100).round()}%', + value: '${(value / max * 100).round()}%', + // enabled: false, + child: Stack( + alignment: Alignment.bottomCenter, + children: [ + ProgressBar( + progress: Duration(seconds: value), + buffered: Duration(seconds: buffer), + total: Duration(seconds: max), + progressBarColor: colorTheme, + baseBarColor: Colors.white.withOpacity(0.2), + bufferedBarColor: colorTheme.withOpacity(0.4), + timeLabelLocation: TimeLabelLocation.none, + thumbColor: colorTheme, + barHeight: 3.5, + thumbRadius: 7, + onDragStart: (duration) { + feedBack(); + controller!.onChangedSliderStart(); + }, + onDragUpdate: (duration) { + double newProgress = + duration.timeStamp.inSeconds / max; + if ((newProgress - lastAnnouncedValue).abs() > 0.02) { + accessibilityDebounce?.cancel(); + accessibilityDebounce = + Timer(const Duration(milliseconds: 200), () { + SemanticsService.announce( + "${(newProgress * 100).round()}%", + TextDirection.ltr); + lastAnnouncedValue = newProgress; + }); + } + controller! + .onUpdatedSliderProgress(duration.timeStamp); + }, + onSeek: (duration) { + controller!.onChangedSliderEnd(); + controller! + .onChangedSlider(duration.inSeconds.toDouble()); + controller!.seekTo( + Duration(seconds: duration.inSeconds), + type: 'slider'); + SemanticsService.announce( + "${(duration.inSeconds / max * 100).round()}%", + TextDirection.ltr); + }, + ), + if (controller?.segmentList.isNotEmpty == true) + Positioned( + left: 0, + right: 0, + bottom: 5.25, + child: IgnorePointer( + child: CustomPaint( + size: Size(double.infinity, 3.5), + painter: SegmentProgressBar( + segmentColors: controller!.segmentList, + ), + ), + ), ), - if (controller?.segmentList.isNotEmpty == true) - CustomPaint( - size: Size(double.infinity, 3.5), - painter: SegmentProgressBar( - segmentColors: controller!.segmentList, + if (controller?.viewPointList.isNotEmpty == true && + controller?.showVP.value == true) + Positioned( + left: 0, + right: 0, + bottom: 5.25, + child: IgnorePointer( + child: CustomPaint( + size: Size(double.infinity, 3.5), + painter: SegmentProgressBar( + segmentColors: controller!.viewPointList, + ), ), ), - if (controller?.viewPointList.isNotEmpty == true && - controller?.showVP.value == true) - CustomPaint( - size: Size(double.infinity, 3.5), - painter: SegmentProgressBar( - segmentColors: controller!.viewPointList, - ), - ), - ], - )), + ), + ], + ), + ), ); }, ),