mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
mod: 代码优化
This commit is contained in:
@@ -73,10 +73,10 @@ class _PlDanmakuState extends State<PlDanmaku> {
|
|||||||
// 播放器状态监听
|
// 播放器状态监听
|
||||||
void playerListener(PlayerStatus? status) {
|
void playerListener(PlayerStatus? status) {
|
||||||
if (status == PlayerStatus.paused) {
|
if (status == PlayerStatus.paused) {
|
||||||
_controller!.pause();
|
_controller?.pause();
|
||||||
}
|
}
|
||||||
if (status == PlayerStatus.playing) {
|
if (status == PlayerStatus.playing) {
|
||||||
_controller!.onResume();
|
_controller?.onResume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -553,8 +553,10 @@ class PlPlayerController {
|
|||||||
|
|
||||||
/// 触发回调事件
|
/// 触发回调事件
|
||||||
for (var element in _statusListeners) {
|
for (var element in _statusListeners) {
|
||||||
|
if (element != null) {
|
||||||
element(event ? PlayerStatus.playing : PlayerStatus.paused);
|
element(event ? PlayerStatus.playing : PlayerStatus.paused);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (videoPlayerController!.state.position.inSeconds != 0) {
|
if (videoPlayerController!.state.position.inSeconds != 0) {
|
||||||
makeHeartBeat(positionSeconds.value, type: 'status');
|
makeHeartBeat(positionSeconds.value, type: 'status');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -655,36 +655,36 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
timeLabelLocation: TimeLabelLocation.none,
|
timeLabelLocation: TimeLabelLocation.none,
|
||||||
thumbColor: colorTheme,
|
thumbColor: colorTheme,
|
||||||
barHeight: 3.5,
|
barHeight: 3.5,
|
||||||
thumbRadius: draggingFixedProgressBar.value ? 7 : 4,
|
thumbRadius: draggingFixedProgressBar.value ? 7 : 2.5,
|
||||||
onDragStart: (duration) {
|
// onDragStart: (duration) {
|
||||||
draggingFixedProgressBar.value = true;
|
// draggingFixedProgressBar.value = true;
|
||||||
feedBack();
|
// feedBack();
|
||||||
_.onChangedSliderStart();
|
// _.onChangedSliderStart();
|
||||||
},
|
// },
|
||||||
onDragUpdate: (duration) {
|
// onDragUpdate: (duration) {
|
||||||
double newProgress = duration.timeStamp.inSeconds / max;
|
// double newProgress = duration.timeStamp.inSeconds / max;
|
||||||
if ((newProgress - _lastAnnouncedValue).abs() > 0.02) {
|
// if ((newProgress - _lastAnnouncedValue).abs() > 0.02) {
|
||||||
_accessibilityDebounce?.cancel();
|
// _accessibilityDebounce?.cancel();
|
||||||
_accessibilityDebounce =
|
// _accessibilityDebounce =
|
||||||
Timer(const Duration(milliseconds: 200), () {
|
// Timer(const Duration(milliseconds: 200), () {
|
||||||
SemanticsService.announce(
|
// SemanticsService.announce(
|
||||||
"${(newProgress * 100).round()}%",
|
// "${(newProgress * 100).round()}%",
|
||||||
TextDirection.ltr);
|
// TextDirection.ltr);
|
||||||
_lastAnnouncedValue = newProgress;
|
// _lastAnnouncedValue = newProgress;
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
_.onUpdatedSliderProgress(duration.timeStamp);
|
// _.onUpdatedSliderProgress(duration.timeStamp);
|
||||||
},
|
// },
|
||||||
onSeek: (duration) {
|
// onSeek: (duration) {
|
||||||
draggingFixedProgressBar.value = false;
|
// draggingFixedProgressBar.value = false;
|
||||||
_.onChangedSliderEnd();
|
// _.onChangedSliderEnd();
|
||||||
_.onChangedSlider(duration.inSeconds.toDouble());
|
// _.onChangedSlider(duration.inSeconds.toDouble());
|
||||||
_.seekTo(Duration(seconds: duration.inSeconds),
|
// _.seekTo(Duration(seconds: duration.inSeconds),
|
||||||
type: 'slider');
|
// type: 'slider');
|
||||||
SemanticsService.announce(
|
// SemanticsService.announce(
|
||||||
"${(duration.inSeconds / max * 100).round()}%",
|
// "${(duration.inSeconds / max * 100).round()}%",
|
||||||
TextDirection.ltr);
|
// TextDirection.ltr);
|
||||||
},
|
// },
|
||||||
),
|
),
|
||||||
// SlideTransition(
|
// SlideTransition(
|
||||||
// position: Tween<Offset>(
|
// position: Tween<Offset>(
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ class Grid {
|
|||||||
static double calculateActualWidth(BuildContext context, double maxCrossAxisExtent, double crossAxisSpacing) {
|
static double calculateActualWidth(BuildContext context, double maxCrossAxisExtent, double crossAxisSpacing) {
|
||||||
double screenWidth = MediaQuery.of(context).size.width;
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
int columnCount = ((screenWidth - crossAxisSpacing) / (maxCrossAxisExtent + crossAxisSpacing)).ceil();
|
int columnCount = ((screenWidth - crossAxisSpacing) / (maxCrossAxisExtent + crossAxisSpacing)).ceil();
|
||||||
|
if (columnCount < 1){
|
||||||
|
columnCount = 1;
|
||||||
|
}
|
||||||
double columnWidth = (screenWidth - crossAxisSpacing) ~/ columnCount - crossAxisSpacing;
|
double columnWidth = (screenWidth - crossAxisSpacing) ~/ columnCount - crossAxisSpacing;
|
||||||
return columnWidth;
|
return columnWidth;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user