From 0cb580ba8edcc15aeee59fa38865740b7cb6ec3d Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 3 Sep 2023 16:30:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=94=81=E5=AE=9A=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E3=80=81=E6=9C=AA=E5=BC=80=E5=90=AF=E8=87=AA=E5=8A=A8=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E6=97=B6=E8=BF=94=E5=9B=9E=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/controller.dart | 9 ++++++- lib/pages/video/detail/view.dart | 14 ++++++++--- lib/plugin/pl_player/controller.dart | 3 +++ lib/plugin/pl_player/view.dart | 34 +++++++++----------------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index ee671f0a..95287df2 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -167,7 +167,13 @@ class VideoDetailController extends GetxController playerInit(); } - Future playerInit({video, audio, seekToTime, duration}) async { + Future playerInit({ + video, + audio, + seekToTime, + duration, + bool autoplay = true, + }) async { /// 设置/恢复 屏幕亮度 if (brightness != null) { ScreenBrightness().setScreenBrightness(brightness!); @@ -199,6 +205,7 @@ class VideoDetailController extends GetxController cid: cid, enableHeart: enableHeart, isFirstTime: isFirstTime, + autoplay: autoplay, ); } diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 639773f6..1c71e578 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -102,6 +102,7 @@ class _VideoDetailPageState extends State plPlayerController!.play(); } + /// 未开启自动播放时触发播放 Future handlePlay() async { await videoDetailController.playerInit(); plPlayerController = videoDetailController.plPlayerController; @@ -111,8 +112,10 @@ class _VideoDetailPageState extends State @override void dispose() { - plPlayerController!.removeStatusLister(playerListener); - plPlayerController!.dispose(); + if (plPlayerController != null) { + plPlayerController!.removeStatusLister(playerListener); + plPlayerController!.dispose(); + } super.dispose(); } @@ -134,9 +137,12 @@ class _VideoDetailPageState extends State // 返回当前页面时 void didPopNext() async { videoDetailController.isFirstTime = false; - videoDetailController.playerInit(); + bool autoplay = + setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true); + videoDetailController.playerInit(autoplay: autoplay); + videoDetailController.autoPlay.value = true; videoIntroController.isPaused = false; - if (_extendNestCtr.position.pixels == 0) { + if (_extendNestCtr.position.pixels == 0 && autoplay) { await Future.delayed(const Duration(milliseconds: 300)); plPlayerController!.play(); } diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index d373bdbc..6ce76100 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -731,6 +731,9 @@ class PlPlayerController { if (videoType.value == 'live') { return; } + if (controlsLock.value) { + return; + } _doubleSpeedStatus.value = val; double currentSpeed = playbackSpeed; if (val) { diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 1b3703d4..3a732862 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -239,35 +239,25 @@ class _PLVideoPlayerState extends State () => Align( alignment: Alignment.topCenter, child: FractionalTranslation( - translation: const Offset(0.0, 1), // 上下偏移量(负数向上偏移) + translation: const Offset(0.0, 0.3), // 上下偏移量(负数向上偏移) child: AnimatedOpacity( curve: Curves.easeInOut, opacity: _.doubleSpeedStatus.value ? 1.0 : 0.0, duration: const Duration(milliseconds: 150), child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - color: const Color(0x88000000), - borderRadius: BorderRadius.circular(64.0), - ), - height: 34.0, - width: 86.0, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - const SizedBox(width: 3), - Image.asset( - 'assets/images/run-pokemon.gif', - height: 20, - ), - const Text( + alignment: Alignment.center, + decoration: BoxDecoration( + color: const Color(0x88000000), + borderRadius: BorderRadius.circular(16.0), + ), + height: 32.0, + width: 70.0, + child: const Center( + child: Text( '倍速中', - style: TextStyle(color: Colors.white, fontSize: 12), + style: TextStyle(color: Colors.white, fontSize: 13), ), - const SizedBox(width: 4), - ], - ), - ), + )), ), ), ),