fix: 长按取消后弹幕速度异常
This commit is contained in:
@ -214,6 +214,8 @@ class PlPlayerController {
|
|||||||
late double fontSizeVal;
|
late double fontSizeVal;
|
||||||
late double danmakuSpeedVal;
|
late double danmakuSpeedVal;
|
||||||
late List speedsList;
|
late List speedsList;
|
||||||
|
// 缓存
|
||||||
|
double? defaultDuration;
|
||||||
|
|
||||||
// 播放顺序相关
|
// 播放顺序相关
|
||||||
PlayRepeat playRepeat = PlayRepeat.pause;
|
PlayRepeat playRepeat = PlayRepeat.pause;
|
||||||
@ -573,8 +575,9 @@ class PlPlayerController {
|
|||||||
await _videoPlayerController?.setRate(speed);
|
await _videoPlayerController?.setRate(speed);
|
||||||
try {
|
try {
|
||||||
DanmakuOption currentOption = danmakuController!.option;
|
DanmakuOption currentOption = danmakuController!.option;
|
||||||
|
defaultDuration ??= currentOption.duration;
|
||||||
DanmakuOption updatedOption = currentOption.copyWith(
|
DanmakuOption updatedOption = currentOption.copyWith(
|
||||||
duration: (currentOption.duration / speed) * playbackSpeed);
|
duration: (defaultDuration! / speed) * playbackSpeed);
|
||||||
danmakuController!.updateOption(updatedOption);
|
danmakuController!.updateOption(updatedOption);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
// fix 长按倍速后放开不恢复
|
// fix 长按倍速后放开不恢复
|
||||||
@ -582,16 +585,16 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 设置倍速
|
/// 设置倍速
|
||||||
Future<void> togglePlaybackSpeed() async {
|
// Future<void> togglePlaybackSpeed() async {
|
||||||
List<double> allowedSpeeds =
|
// List<double> allowedSpeeds =
|
||||||
PlaySpeed.values.map<double>((e) => e.value).toList();
|
// PlaySpeed.values.map<double>((e) => e.value).toList();
|
||||||
int index = allowedSpeeds.indexOf(_playbackSpeed.value);
|
// int index = allowedSpeeds.indexOf(_playbackSpeed.value);
|
||||||
if (index < allowedSpeeds.length - 1) {
|
// if (index < allowedSpeeds.length - 1) {
|
||||||
setPlaybackSpeed(allowedSpeeds[index + 1]);
|
// setPlaybackSpeed(allowedSpeeds[index + 1]);
|
||||||
} else {
|
// } else {
|
||||||
setPlaybackSpeed(allowedSpeeds[0]);
|
// setPlaybackSpeed(allowedSpeeds[0]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// 播放视频
|
/// 播放视频
|
||||||
Future<void> play({bool repeat = false, bool hideControls = true}) async {
|
Future<void> play({bool repeat = false, bool hideControls = true}) async {
|
||||||
|
|||||||
Reference in New Issue
Block a user