opt: video bottom control

Closes #244

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-13 15:04:38 +08:00
parent 675932aa69
commit ba74cb8c01
3 changed files with 114 additions and 108 deletions

View File

@@ -17,11 +17,11 @@ import 'package:PiliPlus/utils/feed_back.dart';
import '../../../common/widgets/audio_video_progress_bar.dart';
class BottomControl extends StatelessWidget implements PreferredSizeWidget {
final PlPlayerController? controller;
final List<Widget>? buildBottomControl;
final PlPlayerController controller;
final Function buildBottomControl;
const BottomControl({
this.controller,
this.buildBottomControl,
required this.controller,
required this.buildBottomControl,
super.key,
});
@@ -37,13 +37,13 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
Obx(
() {
final int value = controller!.sliderPositionSeconds.value;
final int max = controller!.durationSeconds.value.inSeconds;
final int buffer = controller!.bufferedSeconds.value;
final int value = controller.sliderPositionSeconds.value;
final int max = controller.durationSeconds.value.inSeconds;
final int buffer = controller.bufferedSeconds.value;
if (value > max || max <= 0) {
return nil;
}
@@ -57,12 +57,12 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
clipBehavior: Clip.none,
alignment: Alignment.bottomCenter,
children: [
if (controller?.dmTrend.isNotEmpty == true &&
controller?.showDmChart.value == true)
buildDmChart(context, controller!, 4.5),
if (controller?.viewPointList.isNotEmpty == true &&
controller?.showVP.value == true)
buildViewPointWidget(controller!, 8.75),
if (controller.dmTrend.isNotEmpty &&
controller.showDmChart.value)
buildDmChart(context, controller, 4.5),
if (controller.viewPointList.isNotEmpty &&
controller.showVP.value)
buildViewPointWidget(controller, 8.75),
ProgressBar(
progress: Duration(seconds: value),
buffered: Duration(seconds: buffer),
@@ -76,16 +76,16 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
thumbRadius: 7,
onDragStart: (duration) {
feedBack();
controller!.onChangedSliderStart();
controller.onChangedSliderStart();
},
onDragUpdate: (duration) {
double newProgress =
duration.timeStamp.inSeconds / max;
if (controller!.showSeekPreview) {
if (controller!.showPreview.value.not) {
controller!.showPreview.value = true;
if (controller.showSeekPreview) {
if (controller.showPreview.value.not) {
controller.showPreview.value = true;
}
controller!.previewDx.value =
controller.previewDx.value =
duration.localPosition.dx;
}
if ((newProgress - lastAnnouncedValue).abs() > 0.02) {
@@ -98,17 +98,17 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
lastAnnouncedValue = newProgress;
});
}
controller!
controller
.onUpdatedSliderProgress(duration.timeStamp);
},
onSeek: (duration) {
if (controller!.showSeekPreview) {
controller!.showPreview.value = false;
if (controller.showSeekPreview) {
controller.showPreview.value = false;
}
controller!.onChangedSliderEnd();
controller!
controller.onChangedSliderEnd();
controller
.onChangedSlider(duration.inSeconds.toDouble());
controller!.seekTo(
controller.seekTo(
Duration(seconds: duration.inSeconds),
type: 'slider');
SemanticsService.announce(
@@ -116,7 +116,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
TextDirection.ltr);
},
),
if (controller?.segmentList.isNotEmpty == true)
if (controller.segmentList.isNotEmpty)
Positioned(
left: 0,
right: 0,
@@ -125,13 +125,13 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
child: CustomPaint(
size: Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: controller!.segmentList,
segmentColors: controller.segmentList,
),
),
),
),
if (controller?.viewPointList.isNotEmpty == true &&
controller?.showVP.value == true)
if (controller.viewPointList.isNotEmpty &&
controller.showVP.value)
Positioned(
left: 0,
right: 0,
@@ -140,17 +140,17 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
child: CustomPaint(
size: Size(double.infinity, 3.5),
painter: SegmentProgressBar(
segmentColors: controller!.viewPointList,
segmentColors: controller.viewPointList,
),
),
),
),
if (controller?.showSeekPreview == true)
if (controller.showSeekPreview)
Positioned(
left: 0,
right: 0,
bottom: 18,
child: buildSeekPreviewWidget(controller!),
child: buildSeekPreviewWidget(controller),
),
],
),
@@ -158,9 +158,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
);
},
),
Row(
children: [...buildBottomControl!],
),
buildBottomControl(),
const SizedBox(height: 12),
],
),