mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: sponsor block
This commit is contained in:
@@ -4,6 +4,7 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:PiliPalaX/common/widgets/segment_progress_bar.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -114,6 +115,8 @@ class PlPlayerController {
|
||||
Timer? _timerForGettingVolume;
|
||||
Timer? timerForTrackingMouse;
|
||||
|
||||
final RxList<Segment> segmentList = <Segment>[].obs;
|
||||
|
||||
// final Durations durations;
|
||||
|
||||
static List<Map<String, dynamic>> videoFitType = [
|
||||
@@ -403,6 +406,7 @@ class PlPlayerController {
|
||||
// 初始化资源
|
||||
Future<void> setDataSource(
|
||||
DataSource dataSource, {
|
||||
List<Segment>? segmentList,
|
||||
bool autoplay = true,
|
||||
// 默认不循环
|
||||
PlaylistMode looping = PlaylistMode.none,
|
||||
@@ -426,6 +430,7 @@ class PlPlayerController {
|
||||
}) async {
|
||||
try {
|
||||
this.dataSource = dataSource;
|
||||
this.segmentList.value = segmentList ?? <Segment>[];
|
||||
_autoPlay = autoplay;
|
||||
_looping = looping;
|
||||
// 初始化视频倍速
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:PiliPalaX/common/widgets/segment_progress_bar.dart';
|
||||
import 'package:PiliPalaX/http/loading_state.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/introduction/controller.dart';
|
||||
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||
@@ -970,6 +971,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
BottomControl(
|
||||
controller: widget.controller,
|
||||
buildBottomControl: buildBottomControl(),
|
||||
segmentList: _.segmentList,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1015,47 +1017,62 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
// label: '${(value / max * 100).round()}%',
|
||||
value: '${(value / max * 100).round()}%',
|
||||
// enabled: false,
|
||||
child: ProgressBar(
|
||||
progress: Duration(seconds: value),
|
||||
buffered: Duration(seconds: buffer),
|
||||
total: Duration(seconds: max),
|
||||
progressBarColor: colorTheme,
|
||||
baseBarColor: Colors.white.withOpacity(0.2),
|
||||
bufferedBarColor:
|
||||
Theme.of(context).colorScheme.primary.withOpacity(0.4),
|
||||
timeLabelLocation: TimeLabelLocation.none,
|
||||
thumbColor: colorTheme,
|
||||
barHeight: 3.5,
|
||||
thumbRadius: draggingFixedProgressBar.value ? 7 : 2.5,
|
||||
// onDragStart: (duration) {
|
||||
// draggingFixedProgressBar.value = true;
|
||||
// feedBack();
|
||||
// _.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;
|
||||
// });
|
||||
// }
|
||||
// _.onUpdatedSliderProgress(duration.timeStamp);
|
||||
// },
|
||||
// onSeek: (duration) {
|
||||
// draggingFixedProgressBar.value = false;
|
||||
// _.onChangedSliderEnd();
|
||||
// _.onChangedSlider(duration.inSeconds.toDouble());
|
||||
// _.seekTo(Duration(seconds: duration.inSeconds),
|
||||
// type: 'slider');
|
||||
// SemanticsService.announce(
|
||||
// "${(duration.inSeconds / max * 100).round()}%",
|
||||
// TextDirection.ltr);
|
||||
// },
|
||||
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: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary
|
||||
.withOpacity(0.4),
|
||||
timeLabelLocation: TimeLabelLocation.none,
|
||||
thumbColor: colorTheme,
|
||||
barHeight: 3.5,
|
||||
thumbRadius: draggingFixedProgressBar.value ? 7 : 2.5,
|
||||
// onDragStart: (duration) {
|
||||
// draggingFixedProgressBar.value = true;
|
||||
// feedBack();
|
||||
// _.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;
|
||||
// });
|
||||
// }
|
||||
// _.onUpdatedSliderProgress(duration.timeStamp);
|
||||
// },
|
||||
// onSeek: (duration) {
|
||||
// draggingFixedProgressBar.value = false;
|
||||
// _.onChangedSliderEnd();
|
||||
// _.onChangedSlider(duration.inSeconds.toDouble());
|
||||
// _.seekTo(Duration(seconds: duration.inSeconds),
|
||||
// type: 'slider');
|
||||
// SemanticsService.announce(
|
||||
// "${(duration.inSeconds / max * 100).round()}%",
|
||||
// TextDirection.ltr);
|
||||
// },
|
||||
),
|
||||
if (_.segmentList.isNotEmpty)
|
||||
CustomPaint(
|
||||
size: Size(double.infinity, 3.5),
|
||||
painter: SegmentProgressBar(
|
||||
progress: 1,
|
||||
segmentColors: _.segmentList,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// SlideTransition(
|
||||
// position: Tween<Offset>(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:PiliPalaX/common/widgets/segment_progress_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -12,9 +13,11 @@ import '../../../common/widgets/audio_video_progress_bar.dart';
|
||||
class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
||||
final PlPlayerController? controller;
|
||||
final List<Widget>? buildBottomControl;
|
||||
final List<Segment>? segmentList;
|
||||
const BottomControl({
|
||||
this.controller,
|
||||
this.buildBottomControl,
|
||||
this.segmentList,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@@ -49,44 +52,59 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
|
||||
// label: '${(value / max * 100).round()}%',
|
||||
value: '${(value / max * 100).round()}%',
|
||||
// enabled: false,
|
||||
child: 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();
|
||||
_.onChangedSliderStart();
|
||||
},
|
||||
onDragUpdate: (duration) {
|
||||
double newProgress = duration.timeStamp.inSeconds / max;
|
||||
if ((newProgress - _lastAnnouncedValue).abs() > 0.02) {
|
||||
_accessibilityDebounce?.cancel();
|
||||
_accessibilityDebounce =
|
||||
Timer(const Duration(milliseconds: 200), () {
|
||||
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();
|
||||
_.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;
|
||||
});
|
||||
}
|
||||
_.onUpdatedSliderProgress(duration.timeStamp);
|
||||
},
|
||||
onSeek: (duration) {
|
||||
_.onChangedSliderEnd();
|
||||
_.onChangedSlider(duration.inSeconds.toDouble());
|
||||
_.seekTo(Duration(seconds: duration.inSeconds),
|
||||
type: 'slider');
|
||||
SemanticsService.announce(
|
||||
"${(newProgress * 100).round()}%",
|
||||
"${(duration.inSeconds / max * 100).round()}%",
|
||||
TextDirection.ltr);
|
||||
_lastAnnouncedValue = newProgress;
|
||||
});
|
||||
}
|
||||
_.onUpdatedSliderProgress(duration.timeStamp);
|
||||
},
|
||||
onSeek: (duration) {
|
||||
_.onChangedSliderEnd();
|
||||
_.onChangedSlider(duration.inSeconds.toDouble());
|
||||
_.seekTo(Duration(seconds: duration.inSeconds),
|
||||
type: 'slider');
|
||||
SemanticsService.announce(
|
||||
"${(duration.inSeconds / max * 100).round()}%",
|
||||
TextDirection.ltr);
|
||||
},
|
||||
},
|
||||
),
|
||||
if (segmentList?.isNotEmpty == true)
|
||||
CustomPaint(
|
||||
size: Size(double.infinity, 3.5),
|
||||
painter: SegmentProgressBar(
|
||||
progress: 1,
|
||||
segmentColors: segmentList!,
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user