mod: 音量亮度滑动控制条调整

This commit is contained in:
guozhigq
2023-10-21 21:37:22 +08:00
parent b4cc542a4d
commit eec052c47e

View File

@ -74,6 +74,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
late int defaultBtmProgressBehavior; late int defaultBtmProgressBehavior;
late bool enableQuickDouble; late bool enableQuickDouble;
late bool enableBackgroundPlay; late bool enableBackgroundPlay;
late double screenWidth;
void onDoubleTapSeekBackward() { void onDoubleTapSeekBackward() {
_ctr.onDoubleTapSeekBackward(); _ctr.onDoubleTapSeekBackward();
@ -116,6 +117,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
screenWidth = Get.size.width;
animationController = AnimationController( animationController = AnimationController(
vsync: this, duration: const Duration(milliseconds: 300)); vsync: this, duration: const Duration(milliseconds: 300));
videoController = widget.controller.videoController!; videoController = widget.controller.videoController!;
@ -128,7 +130,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
setting.get(SettingBoxKey.enableQuickDouble, defaultValue: true); setting.get(SettingBoxKey.enableQuickDouble, defaultValue: true);
enableBackgroundPlay = enableBackgroundPlay =
setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: false); setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: false);
Future.microtask(() async { Future.microtask(() async {
try { try {
FlutterVolumeController.showSystemUI = true; FlutterVolumeController.showSystemUI = true;
@ -508,7 +509,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
} }
if (tapPosition < sectionWidth) { if (tapPosition < sectionWidth) {
// 左边区域 👈 // 左边区域 👈
final brightness = _ctr.brightnessValue.value - delta / 100.0; double level = (_.isFullScreen.value
? Get.size.height
: screenWidth * 9 / 16) *
3;
final brightness = _ctr.brightnessValue.value - delta / level;
final result = brightness.clamp(0.0, 1.0); final result = brightness.clamp(0.0, 1.0);
setBrightness(result); setBrightness(result);
} else if (tapPosition < sectionWidth * 2) { } else if (tapPosition < sectionWidth * 2) {
@ -531,7 +536,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
_distance = dy; _distance = dy;
} else { } else {
// 右边区域 👈 // 右边区域 👈
final volume = _ctr.volumeValue.value - delta / 100.0; double level = (_.isFullScreen.value
? Get.size.height
: screenWidth * 9 / 16) *
3;
final volume = _ctr.volumeValue.value - delta / level;
final result = volume.clamp(0.0, 1.0); final result = volume.clamp(0.0, 1.0);
setVolume(result); setVolume(result);
} }