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, clipBehavior: Clip.none,
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
AnimatedBuilder( RepaintBoundary(
child: AnimatedBuilder(
animation: animation!, animation: animation!,
builder: (context, child) => CustomPaint( builder: (context, child) => CustomPaint(
size: const Size.square(28), size: const Size.square(28),
@@ -59,6 +60,7 @@ class ActionItem extends StatelessWidget {
), ),
), ),
), ),
),
child, 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 videoDetail = introController.videoDetail.value;
final isSeason = videoDetail.ugcSeason != null; final isSeason = videoDetail.ugcSeason != null;
final isPart = videoDetail.pages != null && videoDetail.pages!.length > 1; final isPart = videoDetail.pages != null && videoDetail.pages!.length > 1;
@@ -659,10 +659,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
children: [ children: [
...userSpecifyItemLeft.map(progressWidget), ...userSpecifyItemLeft.map(progressWidget),
Expanded( Expanded(
child: LayoutBuilder( child: FittedBox(
builder: (context, constraints) => FittedBox(
child: ConstrainedBox( child: ConstrainedBox(
constraints: BoxConstraints(minWidth: constraints.maxWidth), constraints: BoxConstraints(minWidth: maxWidth),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: userSpecifyItemRight.map(progressWidget).toList(), 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 ?? widget.bottomControl ??
BottomControl( BottomControl(
controller: plPlayerController, controller: plPlayerController,
buildBottomControl: () => buildBottomControl: (bottomMaxWidth) =>
buildBottomControl(maxWidth > maxHeight), buildBottomControl(
maxWidth: maxWidth, maxWidth > maxHeight,
bottomMaxWidth,
),
), ),
), ),
], ],
@@ -1472,7 +1472,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
right: 0, right: 0,
bottom: 0.75, bottom: 0.75,
child: IgnorePointer( child: IgnorePointer(
child: RepaintBoundary(
child: CustomPaint( child: CustomPaint(
key: const Key('segmentList'),
size: const Size(double.infinity, 3.5), size: const Size(double.infinity, 3.5),
painter: SegmentProgressBar( painter: SegmentProgressBar(
segmentColors: plPlayerController.segmentList, segmentColors: plPlayerController.segmentList,
@@ -1480,6 +1482,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
), ),
), ),
), ),
),
if (plPlayerController.viewPointList.isNotEmpty && if (plPlayerController.viewPointList.isNotEmpty &&
plPlayerController.showVP.value) plPlayerController.showVP.value)
Positioned( Positioned(
@@ -1487,7 +1490,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
right: 0, right: 0,
bottom: 0.75, bottom: 0.75,
child: IgnorePointer( child: IgnorePointer(
child: RepaintBoundary(
child: CustomPaint( child: CustomPaint(
key: const Key('viewPointList'),
size: const Size(double.infinity, 3.5), size: const Size(double.infinity, 3.5),
painter: SegmentProgressBar( painter: SegmentProgressBar(
segmentColors: plPlayerController.viewPointList, segmentColors: plPlayerController.viewPointList,
@@ -1495,6 +1500,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
), ),
), ),
), ),
),
if (plPlayerController.showSeekPreview) if (plPlayerController.showSeekPreview)
Positioned( Positioned(
left: 0, left: 0,
@@ -1851,6 +1857,10 @@ Widget buildSeekPreviewWidget(
VideoShotData data = plPlayerController.videoShot!['data']; VideoShotData data = plPlayerController.videoShot!['data'];
if (data.index.isNullOrEmpty) {
return const SizedBox.shrink();
}
try { try {
double scale = double scale =
plPlayerController.isFullScreen.value && plPlayerController.isFullScreen.value &&

View File

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