opt progress bar

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-10-04 12:19:44 +08:00
parent 32f6d97256
commit c31e772a63
3 changed files with 86 additions and 440 deletions

View File

@@ -128,9 +128,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
//播放器放缩
bool interacting = false;
// 是否在调整固定进度条
RxBool draggingFixedProgressBar = false.obs;
// 阅读器限制
// Timer? _accessibilityDebounce;
// double _lastAnnouncedValue = -1;
@@ -1086,6 +1083,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
maxWidth = widget.maxWidth;
maxHeight = widget.maxHeight;
final Color primary = theme.colorScheme.primary;
late final bufferedBarColor = primary.withValues(alpha: 0.4);
const TextStyle textStyle = TextStyle(
color: Colors.white,
fontSize: 12,
@@ -1507,13 +1505,10 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
total: Duration(seconds: max),
progressBarColor: primary,
baseBarColor: const Color(0x33FFFFFF),
bufferedBarColor: primary.withValues(alpha: 0.4),
timeLabelLocation: TimeLabelLocation.none,
bufferedBarColor: bufferedBarColor,
thumbColor: primary,
barHeight: 3.5,
thumbRadius: draggingFixedProgressBar.value
? 7
: 2.5,
thumbRadius: 2.5,
);
}),
0,

View File

@@ -30,10 +30,58 @@ class BottomControl extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
Color colorTheme = theme.colorScheme.primary;
Color primary = theme.colorScheme.primary;
final bufferedBarColor = primary.withValues(alpha: 0.4);
//阅读器限制
Timer? accessibilityDebounce;
double lastAnnouncedValue = -1;
void onDragStart(ThumbDragDetails duration) {
feedBack();
controller.onChangedSliderStart(duration.timeStamp);
}
void onDragUpdate(ThumbDragDetails duration, int max) {
if (controller.showSeekPreview) {
controller.updatePreviewIndex(
duration.timeStamp.inSeconds,
);
}
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,
);
}
void onSeek(Duration duration, int max) {
if (controller.showSeekPreview) {
controller.showPreview.value = false;
}
controller
..onChangedSliderEnd()
..onChangedSlider(duration.inSeconds.toDouble())
..seekTo(
Duration(seconds: duration.inSeconds),
isSeek: false,
);
SemanticsService.announce(
"${(duration.inSeconds / max * 100).round()}%",
TextDirection.ltr,
);
}
return Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 10, 12),
child: Column(
@@ -57,57 +105,15 @@ class BottomControl extends StatelessWidget {
progress: Duration(seconds: value),
buffered: Duration(seconds: buffer),
total: Duration(seconds: max),
progressBarColor: colorTheme,
baseBarColor: Colors.white.withValues(alpha: 0.2),
bufferedBarColor: colorTheme.withValues(alpha: 0.4),
timeLabelLocation: TimeLabelLocation.none,
thumbColor: colorTheme,
progressBarColor: primary,
baseBarColor: const Color(0x33FFFFFF),
bufferedBarColor: bufferedBarColor,
thumbColor: primary,
barHeight: 3.5,
thumbRadius: 7,
onDragStart: (duration) {
feedBack();
controller.onChangedSliderStart(duration.timeStamp);
},
onDragUpdate: (duration) {
if (controller.showSeekPreview) {
controller.updatePreviewIndex(
duration.timeStamp.inSeconds,
);
}
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) {
if (controller.showSeekPreview) {
controller.showPreview.value = false;
}
controller
..onChangedSliderEnd()
..onChangedSlider(duration.inSeconds.toDouble())
..seekTo(
Duration(seconds: duration.inSeconds),
isSeek: false,
);
SemanticsService.announce(
"${(duration.inSeconds / max * 100).round()}%",
TextDirection.ltr,
);
},
onDragStart: onDragStart,
onDragUpdate: (e) => onDragUpdate(e, max),
onSeek: (e) => onSeek(e, max),
);
if (Utils.isDesktop) {
return MouseRegion(