From 6da12da92fe0d7479d1b7c4382b0432030583d0c Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 8 Jul 2023 14:19:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=A7=E7=BB=AD=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E3=80=81=E9=87=8D=E6=96=B0=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/controller.dart | 1 - lib/pages/video/detail/view.dart | 34 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index af097a70..e9fafc8a 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -96,7 +96,6 @@ class VideoDetailController extends GetxController { }, ), autoplay: true, - looping: false, seekTo: defaultST, ); } diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 994f2d5a..30eb59f2 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -37,6 +37,7 @@ class _VideoDetailPageState extends State // ); StreamSubscription? _playerEventSubs; bool isPlay = false; + PlayerStatus playerStatus = PlayerStatus.paused; bool isShowCover = true; double doubleOffset = 0; @@ -47,6 +48,7 @@ class _VideoDetailPageState extends State _playerEventSubs = _meeduPlayerController!.onPlayerStatusChanged.listen( (PlayerStatus status) { videoDetailController.markHeartBeat(); + playerStatus = status; if (status == PlayerStatus.playing) { Wakelock.enable(); isPlay = false; @@ -58,10 +60,8 @@ class _VideoDetailPageState extends State isPlay = true; setState(() {}); Wakelock.disable(); - } - // 播放完成停止 or 切换下一个 - if (status == PlayerStatus.completed) { - _meeduPlayerController!.pause(); + // 播放完成停止 or 切换下一个 + if (status == PlayerStatus.completed) {} } }, ); @@ -93,6 +93,12 @@ class _VideoDetailPageState extends State } } + void continuePlay() async { + await _extendNestCtr.animateTo(0, + duration: const Duration(milliseconds: 500), curve: Curves.easeInOut); + _meeduPlayerController!.play(); + } + @override void dispose() { videoDetailController.meeduPlayerController.dispose(); @@ -240,7 +246,7 @@ class _VideoDetailPageState extends State ]; }, pinnedHeaderSliverHeightBuilder: () { - return isPlay + return playerStatus != PlayerStatus.playing ? MediaQuery.of(context).padding.top + 50 : pinnedHeaderHeight; }, @@ -327,16 +333,18 @@ class _VideoDetailPageState extends State scrolledUnderElevation: 0, centerTitle: true, title: TextButton( - onPressed: () { - _extendNestCtr.animateTo(0, - duration: const Duration(milliseconds: 500), - curve: Curves.easeInOut); - }, + onPressed: () => continuePlay(), child: Row( mainAxisSize: MainAxisSize.min, - children: const [ - Icon(Icons.play_arrow_rounded), - Text('继续播放') + children: [ + const Icon(Icons.play_arrow_rounded), + Text( + playerStatus == PlayerStatus.paused + ? '继续播放' + : playerStatus == PlayerStatus.completed + ? '重新播放' + : '播放中', + ) ], ), ),