custom keyboard control

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-09-18 18:20:23 +08:00
parent 2d625e0241
commit 9c552a89e1
6 changed files with 46 additions and 31 deletions

View File

@@ -181,22 +181,23 @@ class _LiveRoomPageState extends State<LiveRoomPage>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (Platform.isAndroid) { if (Platform.isAndroid && Floating().isPipMode) {
if (Floating().isPipMode) { return videoPlayerPanel(
return videoPlayerPanel( isFullScreen,
isFullScreen, width: maxWidth,
width: maxWidth, height: maxHeight,
height: maxHeight, isPipMode: true,
isPipMode: true, needDm: !plPlayerController.pipNoDanmaku,
needDm: !plPlayerController.pipNoDanmaku, );
);
}
} }
return PlayerFocus( if (plPlayerController.keyboardControl) {
plPlayerController: plPlayerController, return PlayerFocus(
onSendDanmaku: _liveRoomController.onSendDanmaku, plPlayerController: plPlayerController,
child: childWhenDisabled, onSendDanmaku: _liveRoomController.onSendDanmaku,
); child: childWhenDisabled,
);
}
return childWhenDisabled;
} }
Widget videoPlayerPanel( Widget videoPlayerPanel(

View File

@@ -130,6 +130,13 @@ List<SettingsModel> get playSettings => [
} }
}, },
), ),
const SettingsModel(
settingsType: SettingsType.sw1tch,
title: '启用键盘控制',
leading: Icon(Icons.keyboard_alt_outlined),
setKey: SettingBoxKey.keyboardControl,
defaultVal: true,
),
const SettingsModel( const SettingsModel(
settingsType: SettingsType.sw1tch, settingsType: SettingsType.sw1tch,
title: '显示 SuperChat', title: '显示 SuperChat',

View File

@@ -1484,21 +1484,23 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
} else { } else {
child = autoChoose(childWhenDisabledAlmostSquare); child = autoChoose(childWhenDisabledAlmostSquare);
} }
child = PlayerFocus( if (videoDetailController.plPlayerController.keyboardControl) {
plPlayerController: videoDetailController.plPlayerController, child = PlayerFocus(
introController: videoDetailController.isUgc plPlayerController: videoDetailController.plPlayerController,
? ugcIntroController introController: videoDetailController.isUgc
: pgcIntroController, ? ugcIntroController
onSendDanmaku: videoDetailController.showShootDanmakuSheet, : pgcIntroController,
canPlay: () { onSendDanmaku: videoDetailController.showShootDanmakuSheet,
if (videoDetailController.autoPlay.value) { canPlay: () {
return true; if (videoDetailController.autoPlay.value) {
} return true;
handlePlay(); }
return false; handlePlay();
}, return false;
child: child, },
); child: child,
);
}
return videoDetailController.plPlayerController.darkVideoPage return videoDetailController.plPlayerController.darkVideoPage
? Theme(data: themeData, child: child) ? Theme(data: themeData, child: child)
: child; : child;

View File

@@ -335,6 +335,7 @@ class PlPlayerController {
late final showDmChart = Pref.showDmChart; late final showDmChart = Pref.showDmChart;
late final showFsScreenshotBtn = Pref.showFsScreenshotBtn; late final showFsScreenshotBtn = Pref.showFsScreenshotBtn;
late final showFsLockBtn = Pref.showFsLockBtn; late final showFsLockBtn = Pref.showFsLockBtn;
late final keyboardControl = Pref.keyboardControl;
late final bool autoExitFullscreen = Pref.autoExitFullscreen; late final bool autoExitFullscreen = Pref.autoExitFullscreen;
late final bool autoPlayEnable = Pref.autoPlayEnable; late final bool autoPlayEnable = Pref.autoPlayEnable;

View File

@@ -24,7 +24,8 @@ abstract class SettingBoxKey {
enableAutoEnter = 'enableAutoEnter', enableAutoEnter = 'enableAutoEnter',
enableAutoExit = 'enableAutoExit', enableAutoExit = 'enableAutoExit',
enableOnlineTotal = 'enableOnlineTotal', enableOnlineTotal = 'enableOnlineTotal',
showSuperChat = 'showSuperChat'; showSuperChat = 'showSuperChat',
keyboardControl = 'keyboardControl';
static const String enableVerticalExpand = 'enableVerticalExpand', static const String enableVerticalExpand = 'enableVerticalExpand',
feedBackEnable = 'feedBackEnable', feedBackEnable = 'feedBackEnable',

View File

@@ -829,4 +829,7 @@ abstract class Pref {
static bool get isWindowMaximized => static bool get isWindowMaximized =>
_setting.get(SettingBoxKey.isWindowMaximized, defaultValue: false); _setting.get(SettingBoxKey.isWindowMaximized, defaultValue: false);
static bool get keyboardControl =>
_setting.get(SettingBoxKey.keyboardControl, defaultValue: true);
} }