opt ua

opt subtitle

opt playertype

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-26 18:41:11 +08:00
parent a05ecd020b
commit 3a78ead3a6
28 changed files with 218 additions and 221 deletions

View File

@@ -16,8 +16,10 @@ import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
import 'package:PiliPlus/plugin/pl_player/controller.dart';
import 'package:PiliPlus/plugin/pl_player/models/bottom_control_type.dart';
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
import 'package:PiliPlus/plugin/pl_player/models/double_tap_type.dart';
import 'package:PiliPlus/plugin/pl_player/models/duration.dart';
import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart';
import 'package:PiliPlus/plugin/pl_player/models/gesture_type.dart';
import 'package:PiliPlus/plugin/pl_player/utils.dart';
import 'package:PiliPlus/plugin/pl_player/widgets/app_bar_ani.dart';
import 'package:PiliPlus/plugin/pl_player/widgets/backward_seek.dart';
@@ -110,7 +112,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
late final RxBool showRestoreScaleBtn = false.obs;
Offset _initialFocalPoint = Offset.zero;
String? _gestureType;
GestureType? _gestureType;
//播放器放缩
bool interacting = false;
@@ -138,20 +140,20 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
}
void doubleTapFuc(String type) {
void doubleTapFuc(DoubleTapType type) {
if (!plPlayerController.enableQuickDouble) {
onDoubleTapCenter();
return;
}
switch (type) {
case 'left':
case DoubleTapType.left:
// 双击左边区域 👈
onDoubleTapSeekBackward();
break;
case 'center':
case DoubleTapType.center:
onDoubleTapCenter();
break;
case 'right':
case DoubleTapType.right:
// 双击右边区域 👈
onDoubleTapSeekForward();
break;
@@ -770,7 +772,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
if (cumulativeDelta.distance < 1) return;
if (cumulativeDelta.dx.abs() >
3 * cumulativeDelta.dy.abs()) {
_gestureType = 'horizontal';
_gestureType = GestureType.horizontal;
} else if (cumulativeDelta.dy.abs() >
3 * cumulativeDelta.dx.abs()) {
if (!plPlayerController.enableSlideVolumeBrightness &&
@@ -787,19 +789,19 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
return;
}
// 左边区域
_gestureType = 'left';
_gestureType = GestureType.left;
} else if (tapPosition < sectionWidth * 2) {
if (!plPlayerController.enableSlideFS) {
return;
}
// 全屏
_gestureType = 'center';
_gestureType = GestureType.center;
} else {
if (!plPlayerController.enableSlideVolumeBrightness) {
return;
}
// 右边区域
_gestureType = 'right';
_gestureType = GestureType.right;
}
} else {
return;
@@ -808,9 +810,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
Offset delta = details.focalPointDelta;
if (_gestureType == 'horizontal') {
if (_gestureType == GestureType.horizontal) {
// live模式下禁用
if (plPlayerController.videoType.value == 'live') return;
if (plPlayerController.isLive) return;
final int curSliderPosition =
plPlayerController.sliderPosition.value.inMilliseconds;
@@ -884,14 +886,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
} catch (_) {}
}
} else if (_gestureType == 'left') {
} else if (_gestureType == GestureType.left) {
// 左边区域 👈
final double level = maxHeight * 3;
final double brightness =
_brightnessValue.value - delta.dy / level;
final double result = brightness.clamp(0.0, 1.0);
setBrightness(result);
} else if (_gestureType == 'center') {
} else if (_gestureType == GestureType.center) {
// 全屏
const double threshold = 2.5; // 滑动阈值
double cumulativeDy =
@@ -902,7 +904,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
if (cumulativeDy > threshold) {
_gestureType = 'center_down';
_gestureType = GestureType.center_down;
if (isFullScreen ^
plPlayerController.fullScreenGestureReverse) {
fullScreenTrigger(
@@ -911,7 +913,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
// if (kDebugMode) debugPrint('center_down:$cumulativeDy');
} else if (cumulativeDy < -threshold) {
_gestureType = 'center_up';
_gestureType = GestureType.center_up;
if (!isFullScreen ^
plPlayerController.fullScreenGestureReverse) {
fullScreenTrigger(
@@ -920,7 +922,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
// if (kDebugMode) debugPrint('center_up:$cumulativeDy');
}
} else if (_gestureType == 'right') {
} else if (_gestureType == GestureType.right) {
// 右边区域
final double level = maxHeight * 0.5;
EasyThrottle.throttle(
@@ -975,25 +977,25 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
final double tapPosition = details.localPosition.dx;
final double sectionWidth = maxWidth / 3;
late String gestureType;
late GestureType gestureType;
if (tapPosition < sectionWidth) {
if (!plPlayerController.enableSlideVolumeBrightness) {
return;
}
// 左边区域
gestureType = 'left';
gestureType = GestureType.left;
} else if (tapPosition < sectionWidth * 2) {
if (!plPlayerController.enableSlideFS) {
return;
}
// 全屏
gestureType = 'center';
gestureType = GestureType.center;
} else {
if (!plPlayerController.enableSlideVolumeBrightness) {
return;
}
// 右边区域
gestureType = 'right';
gestureType = GestureType.right;
}
if (_gestureType != null && _gestureType != gestureType) {
@@ -1001,14 +1003,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
_gestureType = gestureType;
if (_gestureType == 'left') {
if (_gestureType == GestureType.left) {
// 左边区域 👈
final double level = maxHeight * 3;
final double brightness =
_brightnessValue.value - details.delta.dy / level;
final double result = brightness.clamp(0.0, 1.0);
setBrightness(result);
} else if (_gestureType == 'center') {
} else if (_gestureType == GestureType.center) {
// 全屏
const double threshold = 2.5; // 滑动阈值
double cumulativeDy =
@@ -1019,7 +1021,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
if (cumulativeDy > threshold) {
_gestureType = 'center_down';
_gestureType = GestureType.center_down;
if (isFullScreen ^
plPlayerController.fullScreenGestureReverse) {
fullScreenTrigger(
@@ -1028,7 +1030,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
// if (kDebugMode) debugPrint('center_down:$cumulativeDy');
} else if (cumulativeDy < -threshold) {
_gestureType = 'center_up';
_gestureType = GestureType.center_up;
if (!isFullScreen ^
plPlayerController.fullScreenGestureReverse) {
fullScreenTrigger(
@@ -1037,7 +1039,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
// if (kDebugMode) debugPrint('center_up:$cumulativeDy');
}
} else if (_gestureType == 'right') {
} else if (_gestureType == GestureType.right) {
// 右边区域
final double level = maxHeight * 0.5;
EasyThrottle.throttle(
@@ -1065,19 +1067,19 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
if (plPlayerController.controlsLock.value) {
return;
}
if (plPlayerController.videoType.value == 'live') {
doubleTapFuc('center');
if (plPlayerController.isLive) {
doubleTapFuc(DoubleTapType.center);
return;
}
final double tapPosition = details.localPosition.dx;
final double sectionWidth = maxWidth / 4;
String type = 'left';
DoubleTapType type;
if (tapPosition < sectionWidth) {
type = 'left';
type = DoubleTapType.left;
} else if (tapPosition < sectionWidth * 3) {
type = 'center';
type = DoubleTapType.center;
} else {
type = 'right';
type = DoubleTapType.right;
}
doubleTapFuc(type);
},
@@ -1426,7 +1428,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
}
if (plPlayerController.videoType.value == 'live') {
if (plPlayerController.isLive) {
return const SizedBox.shrink();
}
@@ -1551,9 +1553,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
SafeArea(
child: Obx(
() => Visibility(
visible:
plPlayerController.videoType.value != 'live' &&
isFullScreen,
visible: !plPlayerController.isLive && isFullScreen,
child: Align(
alignment: Alignment.centerLeft,
child: FractionalTranslation(
@@ -1895,7 +1895,7 @@ Widget buildSeekPreviewWidget(PlPlayerController plPlayerController) {
try {
double scale =
plPlayerController.isFullScreen.value &&
plPlayerController.direction.value == 'horizontal'
!plPlayerController.isVertical
? 4
: 2.5;
// offset