From 32b0505645aa9b4f255b76062fdf00a5492865ac Mon Sep 17 00:00:00 2001 From: orz12 Date: Fri, 8 Mar 2024 03:30:37 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E6=92=AD=E6=94=BE=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=9D=A1=E7=BB=84=E4=BB=B6=E8=A7=A6=E6=8E=A7=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E6=96=B0=E5=A2=9E=E7=94=BB=E8=B4=A8?= =?UTF-8?q?=E9=9F=B3=E8=B4=A8=E4=BF=AE=E6=94=B9=E5=90=8E=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E4=B8=BA=E9=BB=98=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/controller.dart | 13 +- .../video/detail/widgets/header_control.dart | 154 ++++++++++-------- .../pl_player/widgets/bottom_control.dart | 19 +-- .../pl_player/widgets/play_pause_btn.dart | 4 +- 4 files changed, 109 insertions(+), 81 deletions(-) diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 8a9436ea..39088db3 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -133,7 +133,8 @@ class VideoDetailController extends GetxController // CDN优化 enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: true); // 预设的画质 - cacheVideoQa = setting.get(SettingBoxKey.defaultVideoQa); + cacheVideoQa = setting.get(SettingBoxKey.defaultVideoQa, + defaultValue: VideoQuality.values.last.code); // 预设的解码格式 cacheDecode = setting.get(SettingBoxKey.defaultDecode, defaultValue: VideoDecodeFormats.values.last.code); @@ -194,19 +195,22 @@ class VideoDetailController extends GetxController flag += 4; } } - if (flag == 1) {//currentDecodeFormats + if (flag == 1) { + //currentDecodeFormats firstVideo = videoList.first; } else { if (currentVideoQa == VideoQuality.dolbyVision) { currentDecodeFormats = VideoDecodeFormatsCode.fromString(videoList.first.codecs!)!; firstVideo = videoList.first; - } else if (flag == 2 || flag == 6) {//defaultDecodeFormats + } else if (flag == 2 || flag == 6) { + //defaultDecodeFormats currentDecodeFormats = defaultDecodeFormats; firstVideo = videoList.firstWhere( (i) => i.codecs!.startsWith(defaultDecodeFormats.code), ); - } else if (flag == 4) {//secondDecodeFormats + } else if (flag == 4) { + //secondDecodeFormats currentDecodeFormats = secondDecodeFormats; firstVideo = videoList.firstWhere( (i) => i.codecs!.startsWith(secondDecodeFormats.code), @@ -348,6 +352,7 @@ class VideoDetailController extends GetxController } catch (err) { SmartDialog.showToast('DecodeFormats error: $err'); } + /// 取出符合当前解码格式的videoItem try { firstVideo = videosList.firstWhere( diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index a7129dac..d37af510 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -503,6 +503,15 @@ class _HeaderControlState extends State { final int quality = videoFormat[i].quality!; widget.videoDetailCtr!.currentVideoQa = VideoQualityCode.fromCode(quality)!; + String oldQualityDesc = VideoQualityCode.fromCode( + setting.get(SettingBoxKey.defaultVideoQa, + defaultValue: + VideoQuality.values.last.code))! + .description; + setting.put( + SettingBoxKey.defaultVideoQa, quality); + SmartDialog.showToast( + "默认画质由:$oldQualityDesc 变为:${VideoQualityCode.fromCode(quality)!.description}"); widget.videoDetailCtr!.updatePlayer(); Get.back(); }, @@ -512,10 +521,6 @@ class _HeaderControlState extends State { contentPadding: const EdgeInsets.only(left: 20, right: 20), title: Text(videoFormat[i].newDesc!), - subtitle: Text( - videoFormat[i].format!, - style: subTitleStyle, - ), trailing: currentVideoQa.code == videoFormat[i].quality ? Icon( @@ -523,7 +528,10 @@ class _HeaderControlState extends State { color: Theme.of(context).colorScheme.primary, ) - : const SizedBox(), + : Text( + videoFormat[i].format!, + style: subTitleStyle, + ), ), ] ], @@ -574,6 +582,14 @@ class _HeaderControlState extends State { final int quality = i.id!; widget.videoDetailCtr!.currentAudioQa = AudioQualityCode.fromCode(quality)!; + String oldQualityDesc = AudioQualityCode.fromCode( + setting.get(SettingBoxKey.defaultAudioQa, + defaultValue: + AudioQuality.values.last.code))! + .description; + setting.put(SettingBoxKey.defaultAudioQa, quality); + SmartDialog.showToast( + "默认音质由:$oldQualityDesc 变为:${AudioQualityCode.fromCode(quality)!.description}"); widget.videoDetailCtr!.updatePlayer(); Get.back(); }, @@ -1034,33 +1050,34 @@ class _HeaderControlState extends State { primary: false, centerTitle: false, automaticallyImplyLeading: false, - titleSpacing: 14, + titleSpacing: 10, title: Row( children: [ - // SizedBox(width: MediaQuery.of(context).padding.left,), - ComBtn( - tooltip: '上一页', - icon: const Icon( - FontAwesomeIcons.arrowLeft, - size: 15, - color: Colors.white, - ), - fuc: () => >{ - if (widget.controller!.isFullScreen.value) - {widget.controller!.triggerFullScreen(status: false)} - else - { - if (MediaQuery.of(context).orientation == - Orientation.landscape && - !horizontalScreen) - { - verticalScreenForTwoSeconds(), - }, - Get.back() - } - }, - ), - SizedBox(width: buttonSpace), + SizedBox( + width: 42, + height: 34, + child: IconButton( + tooltip: '上一页', + icon: const Icon( + FontAwesomeIcons.arrowLeft, + size: 15, + color: Colors.white, + ), + onPressed: () => >{ + if (widget.controller!.isFullScreen.value) + {widget.controller!.triggerFullScreen(status: false)} + else + { + if (MediaQuery.of(context).orientation == + Orientation.landscape && + !horizontalScreen) + { + verticalScreenForTwoSeconds(), + }, + Get.back() + } + }, + )), if ((videoIntroController.videoDetail.value.title != null) && (isFullScreen || (!isFullScreen && isLandscape && !horizontalScreen))) ...[ @@ -1069,7 +1086,7 @@ class _HeaderControlState extends State { children: [ ConstrainedBox( constraints: BoxConstraints( - maxWidth: isLandscape ? 400 : 150, maxHeight: 20), + maxWidth: isLandscape ? 400 : 140, maxHeight: 25), child: Marquee( text: videoIntroController.videoDetail.value.title!, style: const TextStyle( @@ -1082,7 +1099,7 @@ class _HeaderControlState extends State { velocity: 40, startAfter: const Duration(seconds: 1), showFadingOnlyWhenScrolling: true, - fadingEdgeStartFraction: 0.1, + fadingEdgeStartFraction: 0, fadingEdgeEndFraction: 0.1, numberOfRounds: 1, startPadding: 0, @@ -1097,28 +1114,31 @@ class _HeaderControlState extends State { '${videoIntroController.total.value}人正在看', style: const TextStyle( color: Colors.white, - fontSize: 12, + fontSize: 11, ), ) ], ) ] else ...[ - ComBtn( - tooltip: '返回主页', - icon: const Icon( - FontAwesomeIcons.house, - size: 15, - color: Colors.white, - ), - fuc: () async { - // 销毁播放器实例 - // await widget.controller!.dispose(type: 'all'); - if (mounted) { - Navigator.popUntil( - context, (Route route) => route.isFirst); - } - }, - ), + SizedBox( + width: 42, + height: 34, + child: IconButton( + tooltip: '返回主页', + icon: const Icon( + FontAwesomeIcons.house, + size: 15, + color: Colors.white, + ), + onPressed: () async { + // 销毁播放器实例 + // await widget.controller!.dispose(type: 'all'); + if (mounted) { + Navigator.popUntil( + context, (Route route) => route.isFirst); + } + }, + )), ], const Spacer(), // ComBtn( @@ -1130,7 +1150,7 @@ class _HeaderControlState extends State { // fuc: () => _.screenshot(), // ), SizedBox( - width: 34, + width: 42, height: 34, child: IconButton( tooltip: '发弹幕', @@ -1145,9 +1165,8 @@ class _HeaderControlState extends State { ), ), ), - SizedBox(width: buttonSpace), SizedBox( - width: 34, + width: 42, height: 34, child: Obx( () => IconButton( @@ -1158,7 +1177,8 @@ class _HeaderControlState extends State { onPressed: () { _.isOpenDanmu.value = !_.isOpenDanmu.value; SmartDialog.showToast( - _.isOpenDanmu.value ? '已临时开启弹幕' : '已临时关闭弹幕', displayTime: const Duration(seconds: 1)); + _.isOpenDanmu.value ? '已临时开启弹幕' : '已临时关闭弹幕', + displayTime: const Duration(seconds: 1)); }, icon: Icon( _.isOpenDanmu.value @@ -1170,10 +1190,9 @@ class _HeaderControlState extends State { ), ), ), - SizedBox(width: buttonSpace), - if (Platform.isAndroid) ...[ + if (Platform.isAndroid) SizedBox( - width: 34, + width: 42, height: 34, child: IconButton( tooltip: '画中画', @@ -1199,16 +1218,21 @@ class _HeaderControlState extends State { ), ), ), - SizedBox(width: buttonSpace), - ], - ComBtn( - tooltip: '更多设置', - icon: const Icon( - Icons.more_vert_outlined, - size: 18, - color: Colors.white, + SizedBox( + width: 42, + height: 34, + child: IconButton( + tooltip: "更多设置", + style: ButtonStyle( + padding: MaterialStateProperty.all(EdgeInsets.zero), + ), + onPressed: () => showSettingSheet(), + icon: const Icon( + Icons.more_vert_outlined, + size: 19, + color: Colors.white, + ), ), - fuc: () => showSettingSheet(), ), ], ), diff --git a/lib/plugin/pl_player/widgets/bottom_control.dart b/lib/plugin/pl_player/widgets/bottom_control.dart index 75e88dd8..b5e7b7ca 100644 --- a/lib/plugin/pl_player/widgets/bottom_control.dart +++ b/lib/plugin/pl_player/widgets/bottom_control.dart @@ -26,7 +26,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { final _ = controller!; const textStyle = TextStyle( color: Colors.white, - fontSize: 12, + fontSize: 11, ); //阅读器限制 Timer? _accessibilityDebounce; @@ -34,7 +34,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { return Container( color: Colors.transparent, height: 90, - padding: const EdgeInsets.only(left: 18, right: 18), + padding: const EdgeInsets.symmetric(horizontal: 10), child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -47,7 +47,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { return nil; } return Padding( - padding: const EdgeInsets.only(left: 7, right: 7, bottom: 6), + padding: const EdgeInsets.only(left: 10, right: 10, bottom: 7), child: Semantics( // label: '${(value / max * 100).round()}%', value: '${(value / max * 100).round()}%', @@ -101,7 +101,6 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { controller: _, ) : nil, - const SizedBox(width: 4), // 播放时间 Obx(() { return Text( @@ -129,7 +128,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { ), const Spacer(), SizedBox( - width: 45, + width: 42, height: 30, child: TextButton( onPressed: () => _.toggleVideoFit(), @@ -150,7 +149,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { width: 0, ) : SizedBox( - width: 45, + width: 42, height: 30, child: PopupMenuButton>( onSelected: (Map value) { @@ -172,7 +171,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { }).toList(); }, child: Container( - width: 45, + width: 42, height: 30, alignment: Alignment.center, child: const Icon( @@ -186,7 +185,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { ), ), SizedBox( - width: 45, + width: 42, height: 30, child: PopupMenuButton( onSelected: (double value) { @@ -209,7 +208,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { }).toList(); }, child: Container( - width: 45, + width: 42, height: 30, alignment: Alignment.center, child: Obx(() => Text("${_.playbackSpeed}X", @@ -221,7 +220,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget { ), // 全屏 SizedBox( - width: 45, + width: 42, height: 30, child: Obx(() => ComBtn( tooltip: _.isFullScreen.value ? '退出全屏' : '全屏', diff --git a/lib/plugin/pl_player/widgets/play_pause_btn.dart b/lib/plugin/pl_player/widgets/play_pause_btn.dart index 1ac942f2..78933ef3 100644 --- a/lib/plugin/pl_player/widgets/play_pause_btn.dart +++ b/lib/plugin/pl_player/widgets/play_pause_btn.dart @@ -64,7 +64,7 @@ class PlayOrPauseButtonState extends State @override Widget build(BuildContext context) { return SizedBox( - width: 34, + width: 42, height: 34, child: IconButton( tooltip: widget.controller!.videoPlayerController!.state.playing @@ -75,7 +75,7 @@ class PlayOrPauseButtonState extends State ), onPressed: player.playOrPause, color: Colors.white, - iconSize: 20, + iconSize: 25, // iconSize: widget.iconSize ?? _theme(context).buttonBarButtonSize, // color: widget.iconColor ?? _theme(context).buttonBarButtonColor, icon: AnimatedIcon(