diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index b35d1004..445737ee 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -791,7 +791,7 @@ class _LiveRoomPageState extends State Obx( () { final enableShowLiveDanmaku = - plPlayerController.enableShowLiveDanmaku.value; + plPlayerController.enableShowDanmaku.value; return SizedBox( width: 34, height: 34, @@ -801,8 +801,7 @@ class _LiveRoomPageState extends State ), onPressed: () { final newVal = !enableShowLiveDanmaku; - plPlayerController.enableShowLiveDanmaku.value = - newVal; + plPlayerController.enableShowDanmaku.value = newVal; if (!plPlayerController.tempPlayerConf) { GStorage.setting.put( SettingBoxKey.enableShowLiveDanmaku, @@ -1035,7 +1034,7 @@ class _LiveDanmakuState extends State { return Obx( () { return AnimatedOpacity( - opacity: plPlayerController.enableShowLiveDanmaku.value + opacity: plPlayerController.enableShowDanmaku.value ? plPlayerController.danmakuOpacity.value : 0, duration: const Duration(milliseconds: 100), diff --git a/lib/pages/live_room/widgets/bottom_control.dart b/lib/pages/live_room/widgets/bottom_control.dart index 0b8c12f0..b7064894 100644 --- a/lib/pages/live_room/widgets/bottom_control.dart +++ b/lib/pages/live_room/widgets/bottom_control.dart @@ -75,7 +75,7 @@ class BottomControl extends StatelessWidget { Obx( () { final enableShowLiveDanmaku = - plPlayerController.enableShowLiveDanmaku.value; + plPlayerController.enableShowDanmaku.value; return ComBtn( tooltip: "${enableShowLiveDanmaku ? '关闭' : '开启'}弹幕", icon: enableShowLiveDanmaku @@ -91,7 +91,7 @@ class BottomControl extends StatelessWidget { ), onTap: () { final newVal = !enableShowLiveDanmaku; - plPlayerController.enableShowLiveDanmaku.value = newVal; + plPlayerController.enableShowDanmaku.value = newVal; if (!plPlayerController.tempPlayerConf) { GStorage.setting.put( SettingBoxKey.enableShowLiveDanmaku, diff --git a/lib/pages/video/widgets/header_control.dart b/lib/pages/video/widgets/header_control.dart index 4bb985c5..ac9c6e6d 100644 --- a/lib/pages/video/widgets/header_control.dart +++ b/lib/pages/video/widgets/header_control.dart @@ -2078,8 +2078,8 @@ class HeaderControlState extends State { } }, icon: extra.isLike - ? const Icon(Icons.thumb_up_off_alt_sharp) - : const Icon(Icons.thumb_up_off_alt_outlined), + ? const Icon(CustomIcons.player_dm_tip_like_solid) + : const Icon(CustomIcons.player_dm_tip_like), ), if (extra.like > 0) Positioned( @@ -2103,7 +2103,7 @@ class HeaderControlState extends State { extra.id, plPlayerController.cid!, ), - icon: const Icon(Icons.delete_outline), + icon: const Icon(CustomIcons.player_dm_tip_recall), ) else iconButton( @@ -2112,7 +2112,7 @@ class HeaderControlState extends State { extra: extra, ctr: plPlayerController, ), - icon: const Icon(Icons.report_problem_outlined), + icon: const Icon(CustomIcons.player_dm_tip_back), ), ], ), diff --git a/lib/pages/video/widgets/player_focus.dart b/lib/pages/video/widgets/player_focus.dart index c29f3c27..e9197c37 100644 --- a/lib/pages/video/widgets/player_focus.dart +++ b/lib/pages/video/widgets/player_focus.dart @@ -167,18 +167,15 @@ class PlayerFocus extends StatelessWidget { return true; case LogicalKeyboardKey.keyD: - if (plPlayerController.isLive) { - final newVal = !plPlayerController.enableShowLiveDanmaku.value; - plPlayerController.enableShowLiveDanmaku.value = newVal; - if (!plPlayerController.tempPlayerConf) { - GStorage.setting.put(SettingBoxKey.enableShowLiveDanmaku, newVal); - } - } else { - final newVal = !plPlayerController.enableShowDanmaku.value; - plPlayerController.enableShowDanmaku.value = newVal; - if (!plPlayerController.tempPlayerConf) { - GStorage.setting.put(SettingBoxKey.enableShowDanmaku, newVal); - } + final newVal = !plPlayerController.enableShowDanmaku.value; + plPlayerController.enableShowDanmaku.value = newVal; + if (!plPlayerController.tempPlayerConf) { + GStorage.setting.put( + plPlayerController.isLive + ? SettingBoxKey.enableShowLiveDanmaku + : SettingBoxKey.enableShowDanmaku, + newVal, + ); } return true; diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 41c99f7d..3b409027 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -246,8 +246,10 @@ class PlPlayerController { bool get isVertical => _isVertical; /// 弹幕开关 - late final RxBool enableShowDanmaku = Pref.enableShowDanmaku.obs; - late final RxBool enableShowLiveDanmaku = Pref.enableShowLiveDanmaku.obs; + late final RxBool _enableShowDanmaku = Pref.enableShowDanmaku.obs; + late final RxBool _enableShowLiveDanmaku = Pref.enableShowLiveDanmaku.obs; + RxBool get enableShowDanmaku => + isLive ? _enableShowLiveDanmaku : _enableShowDanmaku; late final bool autoPiP = Pref.autoPiP; bool get isPipMode => diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 965da5e8..75b689e1 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -287,7 +287,6 @@ class _PLVideoPlayerState extends State FlutterVolumeController.removeListener(); } transformationController.dispose(); - _refreshDmCallback = null; _removeDmAction(); super.dispose(); } @@ -1130,22 +1129,23 @@ class _PLVideoPlayerState extends State if (_suspendedDm == null) { plPlayerController.controls = !plPlayerController.showControls.value; } else { - _dmOffset = details.localPosition; - _refreshDmCallback?.call(); + _dmOffset.value = details.localPosition; } break; } } void _onTapDown(TapDownDetails details) { + if (!plPlayerController.enableShowDanmaku.value) { + _removeDmAction(); + return; + } final ctr = plPlayerController.danmakuController; if (ctr != null) { final pos = details.localPosition; final item = ctr.findSingleDanmaku(pos); if (item == null) { - if (_suspendedDm != null) { - _removeDmAction(); - } + _removeDmAction(); } else if (item != _suspendedDm) { if (item.content.extra == null) { _removeDmAction(); @@ -1153,7 +1153,6 @@ class _PLVideoPlayerState extends State } _suspendedDm?.suspend = false; _suspendedDm = item..suspend = true; - _dmOffset = pos; } } } @@ -1336,15 +1335,15 @@ class _PLVideoPlayerState extends State ), if (plPlayerController.enableTapDm) - Builder( - builder: (context) { - _refreshDmCallback = () { - if (context.mounted) { - ((context) as Element).markNeedsBuild(); - } - }; - if (_dmOffset != null && _suspendedDm != null) { - return _buildDmAction(_suspendedDm!, _dmOffset!); + Obx( + () { + if (!plPlayerController.enableShowDanmaku.value) { + _removeDmAction(); + return const SizedBox.shrink(); + } + final dmOffset = _dmOffset.value; + if (dmOffset != null && _suspendedDm != null) { + return _buildDmAction(_suspendedDm!, dmOffset); } return const SizedBox.shrink(); }, @@ -2200,14 +2199,14 @@ class _PLVideoPlayerState extends State static const _actionItemHeight = 35.0 - _triangleHeight; DanmakuItem? _suspendedDm; - Offset? _dmOffset; - void Function()? _refreshDmCallback; + late final Rxn _dmOffset = Rxn(); void _removeDmAction() { - _suspendedDm?.suspend = false; - _suspendedDm = null; - _dmOffset = null; - _refreshDmCallback?.call(); + if (_suspendedDm != null) { + _suspendedDm?.suspend = false; + _suspendedDm = null; + _dmOffset.value = null; + } } Widget _dmActionItem(