From 1ac152bb49ed159cd7366a20f23227accd882a75 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 20 Nov 2024 22:45:25 +0800 Subject: [PATCH 1/2] feat: dlna switch --- lib/pages/setting/extra_setting.dart | 6 ++++ .../video/detail/widgets/header_control.dart | 33 ++++++++++--------- lib/utils/global_data_cache.dart | 3 ++ lib/utils/storage.dart | 3 +- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index fdc62f13..3e82f2bd 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -190,6 +190,12 @@ class _ExtraSettingState extends State { setKey: SettingBoxKey.enableRelatedVideo, defaultVal: true, ), + const SetSwitchItem( + title: '视频投屏开关', + subTitle: '打开后将在播放器右上角显示投屏入口', + setKey: SettingBoxKey.enableDlna, + defaultVal: false, + ), ListTile( dense: false, title: Text('评论展示', style: titleStyle), diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index f22bf846..bc9167d5 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -16,6 +16,7 @@ import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/pages/video/detail/introduction/widgets/menu_row.dart'; import 'package:pilipala/plugin/pl_player/index.dart'; import 'package:pilipala/plugin/pl_player/models/play_repeat.dart'; +import 'package:pilipala/utils/global_data_cache.dart'; import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/services/shutdown_timer_service.dart'; import '../../../../http/danmaku.dart'; @@ -1237,22 +1238,24 @@ class _HeaderControlState extends State { // ), // fuc: () => _.screenshot(), // ), - ComBtn( - icon: const Icon( - Icons.cast, - size: 19, - color: Colors.white, + if (GlobalDataCache.enableDlna) ...[ + ComBtn( + icon: const Icon( + Icons.cast, + size: 19, + color: Colors.white, + ), + fuc: () async { + showDialog( + context: context, + builder: (BuildContext context) { + return LiveDlnaPage( + datasource: widget.videoDetailCtr!.videoUrl); + }, + ); + }, ), - fuc: () async { - showDialog( - context: context, - builder: (BuildContext context) { - return LiveDlnaPage( - datasource: widget.videoDetailCtr!.videoUrl); - }, - ); - }, - ), + ], if (isFullScreen.value) ...[ SizedBox( width: 56, diff --git a/lib/utils/global_data_cache.dart b/lib/utils/global_data_cache.dart index ea673859..a421f829 100644 --- a/lib/utils/global_data_cache.dart +++ b/lib/utils/global_data_cache.dart @@ -53,6 +53,8 @@ class GlobalDataCache { static late bool enableAutoExpand; // 动态切换 static late bool enableDynamicSwitch; + // 投屏开关 + static bool enableDlna = false; // 私有构造函数 GlobalDataCache._(); @@ -120,5 +122,6 @@ class GlobalDataCache { setting.get(SettingBoxKey.enableAutoExpand, defaultValue: false); enableDynamicSwitch = setting.get(SettingBoxKey.enableDynamicSwitch, defaultValue: true); + enableDlna = setting.get(SettingBoxKey.enableDlna, defaultValue: false); } } diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index a5b36768..49a5c734 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -115,7 +115,8 @@ class SettingBoxKey { enableAi = 'enableAi', enableAutoExpand = 'enableAutoExpand', defaultHomePage = 'defaultHomePage', - enableRelatedVideo = 'enableRelatedVideo'; + enableRelatedVideo = 'enableRelatedVideo', + enableDlna = 'enableDlna'; /// 外观 static const String themeMode = 'themeMode', From b824b75bc64f5b45a784965a99424282c3b69bc9 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 23 Nov 2024 00:01:16 +0800 Subject: [PATCH 2/2] opt: enableDlna switch callFn --- lib/pages/setting/extra_setting.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 3e82f2bd..004f3e9c 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -190,11 +190,14 @@ class _ExtraSettingState extends State { setKey: SettingBoxKey.enableRelatedVideo, defaultVal: true, ), - const SetSwitchItem( + SetSwitchItem( title: '视频投屏开关', subTitle: '打开后将在播放器右上角显示投屏入口', setKey: SettingBoxKey.enableDlna, defaultVal: false, + callFn: (bool val) { + GlobalDataCache.enableDlna = val; + }, ), ListTile( dense: false,