From c53c3a387c47a7cc250fac96d9b800ecfaf2ea6d Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Wed, 26 Mar 2025 23:32:57 +0800 Subject: [PATCH] fix: #539 Signed-off-by: bggRGjQaUbCoE --- lib/plugin/pl_player/controller.dart | 2 +- lib/plugin/pl_player/view.dart | 56 ++++++++++++++-------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index a1c3c427..fc61a40c 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1034,7 +1034,7 @@ class PlPlayerController { Future setPlaybackSpeed(double speed) async { lastPlaybackSpeed = playbackSpeed; - if (speed == playbackSpeed) { + if (speed == _videoPlayerController?.state.rate) { return; } diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 5a001ec8..b25da4f5 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -596,33 +596,35 @@ class _PLVideoPlayerState extends State ), /// 播放速度 - BottomControlType.speed: Container( - height: 30, - margin: const EdgeInsets.symmetric(horizontal: 10), - alignment: Alignment.center, - child: PopupMenuButton( - initialValue: plPlayerController.playbackSpeed, - color: Colors.black.withOpacity(0.8), - itemBuilder: (BuildContext context) { - return plPlayerController.speedList.map((double speed) { - return PopupMenuItem( - height: 35, - padding: const EdgeInsets.only(left: 30), - value: speed, - onTap: () { - plPlayerController.setPlaybackSpeed(speed); - }, - child: Text( - "${speed}X", - style: const TextStyle(color: Colors.white, fontSize: 13), - semanticsLabel: "$speed倍速", - ), - ); - }).toList(); - }, - child: Text("${plPlayerController.playbackSpeed}X", - style: const TextStyle(color: Colors.white, fontSize: 13), - semanticsLabel: "${plPlayerController.playbackSpeed}倍速"), + BottomControlType.speed: Obx( + () => Container( + height: 30, + margin: const EdgeInsets.symmetric(horizontal: 10), + alignment: Alignment.center, + child: PopupMenuButton( + initialValue: plPlayerController.playbackSpeed, + color: Colors.black.withOpacity(0.8), + itemBuilder: (BuildContext context) { + return plPlayerController.speedList.map((double speed) { + return PopupMenuItem( + height: 35, + padding: const EdgeInsets.only(left: 30), + value: speed, + onTap: () { + plPlayerController.setPlaybackSpeed(speed); + }, + child: Text( + "${speed}X", + style: const TextStyle(color: Colors.white, fontSize: 13), + semanticsLabel: "$speed倍速", + ), + ); + }).toList(); + }, + child: Text("${plPlayerController.playbackSpeed}X", + style: const TextStyle(color: Colors.white, fontSize: 13), + semanticsLabel: "${plPlayerController.playbackSpeed}倍速"), + ), ), ),