From 5b953ae0bed61ddede5de4f34a7a9efc7f26fc75 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 7 Sep 2023 08:49:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E7=AE=80=E6=98=93=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/setting/play_setting.dart | 6 +++++ lib/plugin/pl_player/controller.dart | 38 ++++++++++++---------------- lib/plugin/pl_player/view.dart | 4 +++ lib/utils/storage.dart | 1 + 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index a6197def..ad3a212c 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -60,6 +60,12 @@ class _PlaySettingState extends State { setKey: SettingBoxKey.autoPlayEnable, defaultVal: true, ), + const SetSwitchItem( + title: '后台播放', + subTitle: '进入后台时继续播放', + setKey: SettingBoxKey.enableBackgroundPlay, + defaultVal: false, + ), const SetSwitchItem( title: '自动全屏', subTitle: '视频开始播放时进入全屏', diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 6645f621..82c4c1fb 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -353,14 +353,14 @@ class PlPlayerController { var pp = player.platform as NativePlayer; // 音轨 - if (dataSource.audioSource != '' && dataSource.audioSource != null) { - await pp.setProperty( - 'audio-files', - UniversalPlatform.isWindows - ? dataSource.audioSource!.replaceAll(';', '\\;') - : dataSource.audioSource!.replaceAll(':', '\\:'), - ); - } + // if (dataSource.audioSource != '' && dataSource.audioSource != null) { + // await pp.setProperty( + // 'audio-files', + // UniversalPlatform.isWindows + // ? dataSource.audioSource!.replaceAll(';', '\\;') + // : dataSource.audioSource!.replaceAll(':', '\\:'), + // ); + // } // 字幕 if (dataSource.subFiles != '' && dataSource.subFiles != null) { @@ -393,21 +393,15 @@ class PlPlayerController { Media(assetUrl, httpHeaders: dataSource.httpHeaders), play: false, ); - } else if (dataSource.type == DataSourceType.network) { - player.open( - Media(dataSource.videoSource!, httpHeaders: dataSource.httpHeaders), - play: false, - ); - // 音轨 - // player.setAudioTrack( - // AudioTrack.uri(dataSource.audioSource!), - // ); - } else { - player.open( - Media(dataSource.file!.path, httpHeaders: dataSource.httpHeaders), - play: false, - ); } + player.open( + Media(dataSource.videoSource!, httpHeaders: dataSource.httpHeaders), + play: false, + ); + // 音轨 + player.setAudioTrack( + AudioTrack.uri(dataSource.audioSource!), + ); return player; } diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 0c812b18..1db43319 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -72,6 +72,7 @@ class _PLVideoPlayerState extends State late FullScreenMode mode; late int defaultBtmProgressBehavior; late bool enableQuickDouble; + late bool enableBackgroundPlay; void onDoubleTapSeekBackward() { setState(() { @@ -128,6 +129,8 @@ class _PLVideoPlayerState extends State defaultValue: BtmProgresBehavior.values.first.code); enableQuickDouble = setting.get(SettingBoxKey.enableQuickDouble, defaultValue: true); + enableBackgroundPlay = + setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: false); Future.microtask(() async { try { @@ -228,6 +231,7 @@ class _PLVideoPlayerState extends State () => Video( controller: videoController, controls: NoVideoControls, + pauseUponEnteringBackgroundMode: !enableBackgroundPlay, subtitleViewConfiguration: SubtitleViewConfiguration( style: subTitleStyle, textAlign: TextAlign.center, diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 536714eb..6ecd6083 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -107,6 +107,7 @@ class SettingBoxKey { // youtube 双击快进快退 static const String enableQuickDouble = 'enableQuickDouble'; static const String enableShowDanmaku = 'enableShowDanmaku'; + static const String enableBackgroundPlay = 'enableBackgroundPlay'; /// 隐私 static const String blackMidsList = 'blackMidsList'; From 0ad54d8c0b52b886b8cf9e128bbec1cb9363976f Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 7 Sep 2023 19:25:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?mod:=20=E6=8E=A8=E8=8D=90=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=B6=E9=95=BF=E6=98=BE=E7=A4=BA=20issues?= =?UTF-8?q?=20#71=E3=80=81=E6=8E=A8=E8=8D=90=E6=A0=8F=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/widgets/video_card_v.dart | 24 +++++++++++++++++------- lib/pages/rcmd/controller.dart | 2 +- lib/pages/rcmd/view.dart | 3 ++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/common/widgets/video_card_v.dart b/lib/common/widgets/video_card_v.dart index 1a5d4077..cc23f110 100644 --- a/lib/common/widgets/video_card_v.dart +++ b/lib/common/widgets/video_card_v.dart @@ -112,12 +112,22 @@ class VideoCardV extends StatelessWidget { height: maxHeight, ), ), - if (crossAxisCount == 1 && videoItem.duration != null) - PBadge( - bottom: 10, - right: 10, - text: videoItem.duration, - ) + if (videoItem.duration != null) + if (crossAxisCount == 1) ...[ + PBadge( + bottom: 10, + right: 10, + text: videoItem.duration, + ) + ] else ...[ + PBadge( + bottom: 6, + right: 7, + size: 'small', + type: 'gray', + text: videoItem.duration, + ) + ], ], ); }), @@ -174,7 +184,7 @@ class VideoContent extends StatelessWidget { ], ), if (crossAxisCount > 1) ...[ - const SizedBox(height: 3), + const SizedBox(height: 2), VideoStat( videoItem: videoItem, ), diff --git a/lib/pages/rcmd/controller.dart b/lib/pages/rcmd/controller.dart index 183b79bf..1f21ab0d 100644 --- a/lib/pages/rcmd/controller.dart +++ b/lib/pages/rcmd/controller.dart @@ -49,7 +49,7 @@ class RcmdController extends GetxController { videoList.value = res['data']; } } else if (type == 'onRefresh') { - videoList.insertAll(0, res['data']); + videoList.value = res['data']; } else if (type == 'onLoad') { videoList.addAll(res['data']); } diff --git a/lib/pages/rcmd/view.dart b/lib/pages/rcmd/view.dart index c8cf20d4..165613a6 100644 --- a/lib/pages/rcmd/view.dart +++ b/lib/pages/rcmd/view.dart @@ -77,7 +77,8 @@ class _RcmdPageState extends State ), child: RefreshIndicator( onRefresh: () async { - return await _rcmdController.onRefresh(); + await _rcmdController.onRefresh(); + await Future.delayed(const Duration(milliseconds: 300)); }, child: CustomScrollView( controller: _rcmdController.scrollController,