基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
feat(ui): handleSuperResolutionChange (#1353)
UzawaReisaQwQ27d399095b4c
diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dartindex 9a3382ad..acd0b89e 100644--- a/lib/pages/player/player_item.dart+++ b/lib/pages/player/player_item.dart@@ -220,6 +220,73 @@ class _PlayerItemState extends State<PlayerItem>playerTimer = getPlayerTimer();}+ // 启用超分辨率(质量档)时弹出提示+ Future<void> handleSuperResolutionChange(int shaderIndex) async {+ if (!mounted) return;++ final bool isHighMode = shaderIndex == 3;+ final bool alreadyShown = setting.get(SettingBoxKey.superResolutionWarn, defaultValue: false);++ if (isHighMode && !alreadyShown) {+ bool confirmed = false;++ await KazumiDialog.show(builder: (context) {+ bool dontAskAgain = false;++ return StatefulBuilder(builder: (context, setState) {+ return AlertDialog(+ title: const Text('性能提示'),+ content: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ const Text('启用超分辨率(质量档)可能会造成设备卡顿,是否继续?'),+ const SizedBox(height: 12),+ Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ Checkbox(+ value: dontAskAgain,+ onChanged: (value) => setState(() => dontAskAgain = value ?? false),+ ),+ const Text('下次不再询问'),+ ],+ ),+ ],+ ),+ actions: [+ TextButton(+ onPressed: () async {+ if (dontAskAgain) {+ await setting.put(SettingBoxKey.superResolutionWarn, true);+ }+ KazumiDialog.dismiss();+ },+ child: const Text('取消'),+ ),+ TextButton(+ onPressed: () async {+ confirmed = true;+ if (dontAskAgain) {+ await setting.put(SettingBoxKey.superResolutionWarn, true);+ }+ KazumiDialog.dismiss();+ },+ child: const Text('确认'),+ ),+ ],+ );+ });+ });++ if (confirmed) {+ playerController.setShader(shaderIndex);+ }+ } else {+ playerController.setShader(shaderIndex);+ }+ }+void handleFullscreen() {_handleFullscreenChange(context);if (videoPageController.isFullscreen) {@@ -1225,6 +1292,7 @@ class _PlayerItemState extends State<PlayerItem>handleProgressBarDragStart:handleProgressBarDragStart,handleProgressBarDragEnd: handleProgressBarDragEnd,+ handleSuperResolutionChange: handleSuperResolutionChange,animationController: animationController!,keyboardFocus: widget.keyboardFocus,sendDanmaku: widget.sendDanmaku,@@ -1245,6 +1313,7 @@ class _PlayerItemState extends State<PlayerItem>handleProgressBarDragStart:handleProgressBarDragStart,handleProgressBarDragEnd: handleProgressBarDragEnd,+ handleSuperResolutionChange: handleSuperResolutionChange,animationController: animationController!,keyboardFocus: widget.keyboardFocus,handleHove: _handleHove,diff --git a/lib/pages/player/player_item_panel.dart b/lib/pages/player/player_item_panel.dartindex 039a4683..947bfdce 100644--- a/lib/pages/player/player_item_panel.dart+++ b/lib/pages/player/player_item_panel.dart@@ -28,6 +28,7 @@ class PlayerItemPanel extends StatefulWidget {required this.handleFullscreen,required this.handleProgressBarDragStart,required this.handleProgressBarDragEnd,+ required this.handleSuperResolutionChange,required this.animationController,required this.openMenu,required this.keyboardFocus,@@ -48,6 +49,7 @@ class PlayerItemPanel extends StatefulWidget {final void Function() handleFullscreen;final void Function(ThumbDragDetails details) handleProgressBarDragStart;final void Function() handleProgressBarDragEnd;+ final Future<void> Function(int shaderIndex) handleSuperResolutionChange;final AnimationController animationController;final FocusNode keyboardFocus;final void Function() startHideTimer;@@ -1102,7 +1104,7 @@ class _PlayerItemPanelState extends State<PlayerItemPanel> {3,(int index) => MenuItemButton(onPressed: () =>- playerController.setShader(index + 1),+ widget.handleSuperResolutionChange(index + 1),child: Container(height: 48,constraints:diff --git a/lib/pages/player/smallest_player_item_panel.dart b/lib/pages/player/smallest_player_item_panel.dartindex 92452932..0be075bf 100644--- a/lib/pages/player/smallest_player_item_panel.dart+++ b/lib/pages/player/smallest_player_item_panel.dart@@ -26,6 +26,7 @@ class SmallestPlayerItemPanel extends StatefulWidget {required this.handleFullscreen,required this.handleProgressBarDragStart,required this.handleProgressBarDragEnd,+ required this.handleSuperResolutionChange,required this.animationController,required this.keyboardFocus,required this.handleHove,@@ -44,6 +45,7 @@ class SmallestPlayerItemPanel extends StatefulWidget {final void Function() handleFullscreen;final void Function(ThumbDragDetails details) handleProgressBarDragStart;final void Function() handleProgressBarDragEnd;+ final Future<void> Function(int shaderIndex) handleSuperResolutionChange;final void Function() handleHove;final AnimationController animationController;final FocusNode keyboardFocus;@@ -516,7 +518,7 @@ class _SmallestPlayerItemPanelState extends State<SmallestPlayerItemPanel> {3,(int index) => MenuItemButton(onPressed: () =>- playerController.setShader(index + 1),+ widget.handleSuperResolutionChange(index + 1),child: Container(height: 48,constraints: BoxConstraints(minWidth: 112),diff --git a/lib/pages/settings/super_resolution_settings.dart b/lib/pages/settings/super_resolution_settings.dartindex 7231a868..b7b79183 100644--- a/lib/pages/settings/super_resolution_settings.dart+++ b/lib/pages/settings/super_resolution_settings.dart@@ -14,12 +14,20 @@ class SuperResolutionSettings extends StatefulWidget {class _SuperResolutionSettingsState extends State<SuperResolutionSettings> {late final Box setting = GStorage.setting;+ late bool promptOnEnable;late final ValueNotifier<String> superResolutionType = ValueNotifier<String>(setting.get(SettingBoxKey.defaultSuperResolutionType, defaultValue: 1).toString(),);+ @override+ void initState() {+ super.initState();+ promptOnEnable =+ setting.get(SettingBoxKey.superResolutionWarn, defaultValue: false);+ }+@overrideWidget build(BuildContext context) {return Scaffold(@@ -29,6 +37,23 @@ class _SuperResolutionSettingsState extends State<SuperResolutionSettings> {body: SettingsList(maxWidth: 1000,sections: [+ SettingsSection(+ title: const Text('默认行为'),+ tiles: [+ SettingsTile.switchTile(+ title: const Text('关闭提示'),+ description:+ const Text('关闭每次启用超分辨率时的提示'),+ initialValue: promptOnEnable,+ onToggle: (value) async {+ promptOnEnable = value ?? false;+ await setting.put(SettingBoxKey.superResolutionWarn, promptOnEnable);+ if (mounted) setState(() {});+ },+ ),+ ],+ ),+SettingsSection(title: const Text('超分辨率需要启用硬件解码, 若启用硬件解码后仍然不生效, 尝试切换硬件解码器为 auto-copy'),diff --git a/lib/utils/storage.dart b/lib/utils/storage.dartindex 19dde609..5af313b6 100644--- a/lib/utils/storage.dart+++ b/lib/utils/storage.dart@@ -251,5 +251,6 @@ class SettingBoxKey {playerDebugMode = 'playerDebugMode',syncPlayEndPoint = 'syncPlayEndPoint',androidEnableOpenSLES = 'androidEnableOpenSLES',- defaultSuperResolutionType = 'defaultSuperResolutionType';+ defaultSuperResolutionType = 'defaultSuperResolutionType',+ superResolutionWarn = 'superResolutionWarn';}