opt video bar

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-12 13:32:35 +08:00
parent be5a1af040
commit 1826b6a059
3 changed files with 193 additions and 158 deletions

View File

@@ -49,7 +49,8 @@ class ActionItem extends StatelessWidget {
clipBehavior: Clip.none,
alignment: Alignment.center,
children: [
AnimatedBuilder(
RepaintBoundary(
child: AnimatedBuilder(
animation: animation!,
builder: (context, child) => CustomPaint(
size: const Size.square(28),
@@ -59,6 +60,7 @@ class ActionItem extends StatelessWidget {
),
),
),
),
child,
],
);

View File

@@ -247,7 +247,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
// 动态构建底部控制条
Widget buildBottomControl(bool isLandscape) {
Widget buildBottomControl(bool isLandscape, double maxWidth) {
final videoDetail = introController.videoDetail.value;
final isSeason = videoDetail.ugcSeason != null;
final isPart = videoDetail.pages != null && videoDetail.pages!.length > 1;
@@ -659,10 +659,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
children: [
...userSpecifyItemLeft.map(progressWidget),
Expanded(
child: LayoutBuilder(
builder: (context, constraints) => FittedBox(
child: FittedBox(
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: constraints.maxWidth),
constraints: BoxConstraints(minWidth: maxWidth),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: userSpecifyItemRight.map(progressWidget).toList(),
@@ -670,7 +669,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
),
),
),
),
],
);
}
@@ -1292,9 +1290,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
widget.bottomControl ??
BottomControl(
controller: plPlayerController,
buildBottomControl: () =>
buildBottomControl(maxWidth > maxHeight),
maxWidth: maxWidth,
buildBottomControl: (bottomMaxWidth) =>
buildBottomControl(
maxWidth > maxHeight,
bottomMaxWidth,
),
),
),
],
@@ -1472,7 +1472,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
right: 0,
bottom: 0.75,
child: IgnorePointer(
child: RepaintBoundary(
child: CustomPaint(
key: const Key('segmentList'),
size: const Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: plPlayerController.segmentList,
@@ -1480,6 +1482,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
),
),
),
),
if (plPlayerController.viewPointList.isNotEmpty &&
plPlayerController.showVP.value)
Positioned(
@@ -1487,7 +1490,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
right: 0,
bottom: 0.75,
child: IgnorePointer(
child: RepaintBoundary(
child: CustomPaint(
key: const Key('viewPointList'),
size: const Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: plPlayerController.viewPointList,
@@ -1495,6 +1500,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
),
),
),
),
if (plPlayerController.showSeekPreview)
Positioned(
left: 0,
@@ -1851,6 +1857,10 @@ Widget buildSeekPreviewWidget(
VideoShotData data = plPlayerController.videoShot!['data'];
if (data.index.isNullOrEmpty) {
return const SizedBox.shrink();
}
try {
double scale =
plPlayerController.isFullScreen.value &&

View File

@@ -13,13 +13,11 @@ class BottomControl extends StatelessWidget {
const BottomControl({
required this.controller,
required this.buildBottomControl,
required this.maxWidth,
super.key,
});
final PlPlayerController controller;
final Widget Function() buildBottomControl;
final double maxWidth;
final Widget Function(double maxWidth) buildBottomControl;
@override
Widget build(BuildContext context) {
@@ -30,7 +28,10 @@ class BottomControl extends StatelessWidget {
double lastAnnouncedValue = -1;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
child: LayoutBuilder(
builder: (context, constraints) {
final maxWidth = constraints.maxWidth;
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Obx(
@@ -42,7 +43,11 @@ class BottomControl extends StatelessWidget {
return const SizedBox.shrink();
}
return Padding(
padding: const EdgeInsets.only(left: 10, right: 10, bottom: 7),
padding: const EdgeInsets.only(
left: 10,
right: 10,
bottom: 7,
),
child: Semantics(
value: '${(value / max * 100).round()}%',
child: Stack(
@@ -54,7 +59,11 @@ class BottomControl extends StatelessWidget {
buildDmChart(theme, controller, 4.5),
if (controller.viewPointList.isNotEmpty &&
controller.showVP.value)
buildViewPointWidget(controller, 8.75, maxWidth),
buildViewPointWidget(
controller,
8.75,
maxWidth - 20,
),
ProgressBar(
progress: Duration(seconds: value),
buffered: Duration(seconds: buffer),
@@ -68,7 +77,9 @@ class BottomControl extends StatelessWidget {
thumbRadius: 7,
onDragStart: (duration) {
feedBack();
controller.onChangedSliderStart(duration.timeStamp);
controller.onChangedSliderStart(
duration.timeStamp,
);
},
onDragUpdate: (duration) {
double newProgress =
@@ -80,7 +91,8 @@ class BottomControl extends StatelessWidget {
controller.previewDx.value =
duration.localPosition.dx;
}
if ((newProgress - lastAnnouncedValue).abs() > 0.02) {
if ((newProgress - lastAnnouncedValue).abs() >
0.02) {
accessibilityDebounce?.cancel();
accessibilityDebounce = Timer(
const Duration(milliseconds: 200),
@@ -120,7 +132,9 @@ class BottomControl extends StatelessWidget {
right: 0,
bottom: 5.25,
child: IgnorePointer(
child: RepaintBoundary(
child: CustomPaint(
key: const Key('segmentList'),
size: const Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: controller.segmentList,
@@ -128,6 +142,7 @@ class BottomControl extends StatelessWidget {
),
),
),
),
if (controller.viewPointList.isNotEmpty &&
controller.showVP.value)
Positioned(
@@ -135,7 +150,9 @@ class BottomControl extends StatelessWidget {
right: 0,
bottom: 5.25,
child: IgnorePointer(
child: RepaintBoundary(
child: CustomPaint(
key: const Key('viewPointList'),
size: const Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: controller.viewPointList,
@@ -143,13 +160,17 @@ class BottomControl extends StatelessWidget {
),
),
),
),
if (controller.showSeekPreview &&
controller.showControls.value)
Positioned(
left: 0,
right: 0,
bottom: 18,
child: buildSeekPreviewWidget(controller, maxWidth),
child: buildSeekPreviewWidget(
controller,
maxWidth - 20,
),
),
],
),
@@ -157,9 +178,11 @@ class BottomControl extends StatelessWidget {
);
},
),
buildBottomControl(),
buildBottomControl(maxWidth),
const SizedBox(height: 12),
],
);
},
),
);
}