From d0590933e071d55563ed9a166f3bcd7245a6f791 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 17 Oct 2023 23:00:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=95=BF=E6=8C=89=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=90=8E=E5=BC=B9=E5=B9=95=E9=80=9F=E5=BA=A6=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugin/pl_player/controller.dart | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 2c116b16..07fabb76 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -214,6 +214,8 @@ class PlPlayerController { late double fontSizeVal; late double danmakuSpeedVal; late List speedsList; + // 缓存 + double? defaultDuration; // 播放顺序相关 PlayRepeat playRepeat = PlayRepeat.pause; @@ -573,8 +575,9 @@ class PlPlayerController { await _videoPlayerController?.setRate(speed); try { DanmakuOption currentOption = danmakuController!.option; + defaultDuration ??= currentOption.duration; DanmakuOption updatedOption = currentOption.copyWith( - duration: (currentOption.duration / speed) * playbackSpeed); + duration: (defaultDuration! / speed) * playbackSpeed); danmakuController!.updateOption(updatedOption); } catch (_) {} // fix 长按倍速后放开不恢复 @@ -582,16 +585,16 @@ class PlPlayerController { } /// 设置倍速 - Future togglePlaybackSpeed() async { - List allowedSpeeds = - PlaySpeed.values.map((e) => e.value).toList(); - int index = allowedSpeeds.indexOf(_playbackSpeed.value); - if (index < allowedSpeeds.length - 1) { - setPlaybackSpeed(allowedSpeeds[index + 1]); - } else { - setPlaybackSpeed(allowedSpeeds[0]); - } - } + // Future togglePlaybackSpeed() async { + // List allowedSpeeds = + // PlaySpeed.values.map((e) => e.value).toList(); + // int index = allowedSpeeds.indexOf(_playbackSpeed.value); + // if (index < allowedSpeeds.length - 1) { + // setPlaybackSpeed(allowedSpeeds[index + 1]); + // } else { + // setPlaybackSpeed(allowedSpeeds[0]); + // } + // } /// 播放视频 Future play({bool repeat = false, bool hideControls = true}) async {