mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 音量抖动由平滑改为节流
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:ui';
|
|||||||
|
|
||||||
import 'package:PiliPalaX/pages/video/detail/introduction/controller.dart';
|
import 'package:PiliPalaX/pages/video/detail/introduction/controller.dart';
|
||||||
import 'package:PiliPalaX/utils/id_utils.dart';
|
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@@ -91,8 +92,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
|
|
||||||
// 用于记录上一次全屏切换手势触发时间,避免误触
|
// 用于记录上一次全屏切换手势触发时间,避免误触
|
||||||
DateTime? lastFullScreenToggleTime;
|
DateTime? lastFullScreenToggleTime;
|
||||||
// 记录上一次音量调整值作平均,避免音量调整抖动
|
|
||||||
double lastVolume = -1.0;
|
|
||||||
// 是否在调整固定进度条
|
// 是否在调整固定进度条
|
||||||
RxBool draggingFixedProgressBar = false.obs;
|
RxBool draggingFixedProgressBar = false.obs;
|
||||||
// 阅读器限制
|
// 阅读器限制
|
||||||
@@ -839,14 +838,12 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
} else {
|
} else {
|
||||||
// 右边区域 👈
|
// 右边区域 👈
|
||||||
final double level = renderBox.size.height * 0.5;
|
final double level = renderBox.size.height * 0.5;
|
||||||
if (lastVolume < 0) {
|
EasyThrottle.throttle(
|
||||||
lastVolume = _volumeValue.value;
|
'setVolume', const Duration(milliseconds: 20), () {
|
||||||
}
|
final double volume = _volumeValue.value - delta / level;
|
||||||
final double volume =
|
final double result = volume.clamp(0.0, 1.0);
|
||||||
(lastVolume + _volumeValue.value - delta / level) / 2;
|
setVolume(result);
|
||||||
final double result = volume.clamp(0.0, 1.0);
|
});
|
||||||
lastVolume = result;
|
|
||||||
setVolume(result);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onVerticalDragEnd: (DragEndDetails details) {},
|
onVerticalDragEnd: (DragEndDetails details) {},
|
||||||
@@ -1043,12 +1040,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
Obx(() {
|
Obx(() {
|
||||||
if (_.dataStatus.loading || _.isBuffering.value) {
|
if (_.dataStatus.loading || _.isBuffering.value) {
|
||||||
return Center(
|
return Center(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_.refreshPlayer();
|
_.refreshPlayer();
|
||||||
},
|
},
|
||||||
child:
|
child: Container(
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(30),
|
padding: const EdgeInsets.all(30),
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
|
|||||||
Reference in New Issue
Block a user