mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom fs danmuku fontsize
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -32,13 +32,14 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
||||
// bool danmuPlayStatus = true;
|
||||
Box setting = GStorage.setting;
|
||||
late bool enableShowDanmaku;
|
||||
late List blockTypes;
|
||||
late double showArea;
|
||||
late double opacityVal;
|
||||
late double fontSizeVal;
|
||||
late double danmakuDurationVal;
|
||||
late double strokeWidth;
|
||||
late int fontWeight;
|
||||
// late List blockTypes;
|
||||
// late double showArea;
|
||||
// late double opacityVal;
|
||||
// late double fontSizeVal;
|
||||
// late double fontSizeFSVal;
|
||||
// late double danmakuDurationVal;
|
||||
// late double strokeWidth;
|
||||
// late int fontWeight;
|
||||
int latestAddedPosition = -1;
|
||||
bool showDanmaku = true;
|
||||
bool? _isFullScreen;
|
||||
@@ -94,13 +95,14 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
||||
}
|
||||
}
|
||||
});
|
||||
blockTypes = playerController.blockTypes;
|
||||
showArea = playerController.showArea;
|
||||
opacityVal = playerController.opacityVal;
|
||||
fontSizeVal = playerController.fontSizeVal;
|
||||
strokeWidth = playerController.strokeWidth;
|
||||
fontWeight = playerController.fontWeight;
|
||||
danmakuDurationVal = playerController.danmakuDurationVal;
|
||||
// blockTypes = playerController.blockTypes;
|
||||
// showArea = playerController.showArea;
|
||||
// opacityVal = playerController.opacityVal;
|
||||
// fontSizeVal = playerController.fontSizeVal;
|
||||
// fontSizeFSVal = playerController.fontSizeFSVal;
|
||||
// strokeWidth = playerController.strokeWidth;
|
||||
// fontWeight = playerController.fontWeight;
|
||||
// danmakuDurationVal = playerController.danmakuDurationVal;
|
||||
}
|
||||
|
||||
// 播放器状态监听
|
||||
@@ -157,8 +159,8 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
||||
|
||||
double _getFontSize(isFullScreen) =>
|
||||
isFullScreen == false || widget.isPipMode == true
|
||||
? 15 * fontSizeVal
|
||||
: 15 * fontSizeVal * 1.2;
|
||||
? 15 * playerController.fontSizeVal
|
||||
: 15 * playerController.fontSizeFSVal;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -174,14 +176,15 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
||||
},
|
||||
option: DanmakuOption(
|
||||
fontSize: _getFontSize(playerController.isFullScreen.value),
|
||||
fontWeight: fontWeight,
|
||||
area: showArea,
|
||||
opacity: opacityVal,
|
||||
hideTop: blockTypes.contains(5),
|
||||
hideScroll: blockTypes.contains(2),
|
||||
hideBottom: blockTypes.contains(4),
|
||||
duration: danmakuDurationVal / playerController.playbackSpeed,
|
||||
strokeWidth: strokeWidth,
|
||||
fontWeight: playerController.fontWeight,
|
||||
area: playerController.showArea,
|
||||
opacity: playerController.opacityVal,
|
||||
hideTop: playerController.blockTypes.contains(5),
|
||||
hideScroll: playerController.blockTypes.contains(2),
|
||||
hideBottom: playerController.blockTypes.contains(4),
|
||||
duration: playerController.danmakuDurationVal /
|
||||
playerController.playbackSpeed,
|
||||
strokeWidth: playerController.strokeWidth,
|
||||
// initDuration /
|
||||
// (danmakuSpeedVal * widget.playerController.playbackSpeed),
|
||||
),
|
||||
|
||||
@@ -42,14 +42,15 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
late final _node = FocusNode();
|
||||
late final _ctr = TextEditingController();
|
||||
|
||||
late bool enableShowDanmaku;
|
||||
late List blockTypes;
|
||||
late double showArea;
|
||||
late double opacityVal;
|
||||
late double fontSizeVal;
|
||||
late double danmakuDurationVal;
|
||||
late double strokeWidth;
|
||||
late int fontWeight;
|
||||
// late bool enableShowDanmaku;
|
||||
// late List blockTypes;
|
||||
// late double showArea;
|
||||
// late double opacityVal;
|
||||
// late double fontSizeVal;
|
||||
// late double fontSizeFSVal;
|
||||
// late double danmakuDurationVal;
|
||||
// late double strokeWidth;
|
||||
// late int fontWeight;
|
||||
int latestAddedPosition = -1;
|
||||
bool? _isFullScreen;
|
||||
bool? _isPipMode;
|
||||
@@ -93,20 +94,21 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
|
||||
double _getFontSize(isFullScreen) {
|
||||
return isFullScreen == false || _isPipMode != false
|
||||
? 15 * fontSizeVal
|
||||
: 15 * fontSizeVal * 1.2;
|
||||
? 15 * plPlayerController.fontSizeVal
|
||||
: 15 * plPlayerController.fontSizeFSVal;
|
||||
}
|
||||
|
||||
Future<void> videoSourceInit() async {
|
||||
_futureBuilder = _liveRoomController.queryLiveInfoH5();
|
||||
plPlayerController = _liveRoomController.plPlayerController;
|
||||
blockTypes = plPlayerController.blockTypes;
|
||||
showArea = plPlayerController.showArea;
|
||||
opacityVal = plPlayerController.opacityVal;
|
||||
fontSizeVal = plPlayerController.fontSizeVal;
|
||||
strokeWidth = plPlayerController.strokeWidth;
|
||||
fontWeight = plPlayerController.fontWeight;
|
||||
danmakuDurationVal = plPlayerController.danmakuDurationVal;
|
||||
// blockTypes = plPlayerController.blockTypes;
|
||||
// showArea = plPlayerController.showArea;
|
||||
// opacityVal = plPlayerController.opacityVal;
|
||||
// fontSizeVal = plPlayerController.fontSizeVal;
|
||||
// fontSizeFSVal = plPlayerController.fontSizeFSVal;
|
||||
// strokeWidth = plPlayerController.strokeWidth;
|
||||
// fontWeight = plPlayerController.fontWeight;
|
||||
// danmakuDurationVal = plPlayerController.danmakuDurationVal;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -157,15 +159,15 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
||||
option: DanmakuOption(
|
||||
fontSize:
|
||||
_getFontSize(plPlayerController.isFullScreen.value),
|
||||
fontWeight: fontWeight,
|
||||
area: showArea,
|
||||
opacity: opacityVal,
|
||||
hideTop: blockTypes.contains(5),
|
||||
hideScroll: blockTypes.contains(2),
|
||||
hideBottom: blockTypes.contains(4),
|
||||
duration:
|
||||
danmakuDurationVal / plPlayerController.playbackSpeed,
|
||||
strokeWidth: strokeWidth,
|
||||
fontWeight: plPlayerController.fontWeight,
|
||||
area: plPlayerController.showArea,
|
||||
opacity: plPlayerController.opacityVal,
|
||||
hideTop: plPlayerController.blockTypes.contains(5),
|
||||
hideScroll: plPlayerController.blockTypes.contains(2),
|
||||
hideBottom: plPlayerController.blockTypes.contains(4),
|
||||
duration: plPlayerController.danmakuDurationVal /
|
||||
plPlayerController.playbackSpeed,
|
||||
strokeWidth: plPlayerController.strokeWidth,
|
||||
// initDuration /
|
||||
// (danmakuSpeedVal * widget.playerController.playbackSpeed),
|
||||
),
|
||||
|
||||
@@ -892,6 +892,8 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
double opacityVal = widget.controller!.opacityVal;
|
||||
// 字体大小
|
||||
double fontSizeVal = widget.controller!.fontSizeVal;
|
||||
// 全屏字体大小
|
||||
double fontSizeFSVal = widget.controller!.fontSizeFSVal;
|
||||
// 弹幕速度
|
||||
double danmakuDurationVal = widget.controller!.danmakuDurationVal;
|
||||
// 弹幕描边
|
||||
@@ -1198,6 +1200,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
widget.controller!.fontSizeVal = fontSizeVal;
|
||||
widget.controller?.putDanmakuSettings();
|
||||
setState(() {});
|
||||
if (widget.controller?.isFullScreen.value == false) {
|
||||
try {
|
||||
final DanmakuOption currentOption =
|
||||
danmakuController.option;
|
||||
@@ -1207,6 +1210,50 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
);
|
||||
danmakuController.updateOption(updatedOption);
|
||||
} catch (_) {}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Text('全屏字体大小 ${(fontSizeFSVal * 100).toStringAsFixed(1)}%'),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 0,
|
||||
bottom: 6,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
child: SliderTheme(
|
||||
data: SliderThemeData(
|
||||
trackShape: MSliderTrackShape(),
|
||||
thumbColor: Theme.of(context).colorScheme.primary,
|
||||
activeTrackColor: Theme.of(context).colorScheme.primary,
|
||||
trackHeight: 10,
|
||||
thumbShape: const RoundSliderThumbShape(
|
||||
enabledThumbRadius: 6.0),
|
||||
),
|
||||
child: Slider(
|
||||
min: 0.5,
|
||||
max: 2.5,
|
||||
value: fontSizeFSVal,
|
||||
divisions: 20,
|
||||
label: '${(fontSizeFSVal * 100).toStringAsFixed(1)}%',
|
||||
onChanged: (double val) {
|
||||
fontSizeFSVal = val;
|
||||
widget.controller!.fontSizeFSVal = fontSizeFSVal;
|
||||
widget.controller?.putDanmakuSettings();
|
||||
setState(() {});
|
||||
if (widget.controller?.isFullScreen.value == true) {
|
||||
try {
|
||||
final DanmakuOption currentOption =
|
||||
danmakuController.option;
|
||||
final DanmakuOption updatedOption =
|
||||
currentOption.copyWith(
|
||||
fontSize: (15 * fontSizeFSVal).toDouble(),
|
||||
);
|
||||
danmakuController.updateOption(updatedOption);
|
||||
} catch (_) {}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@@ -248,6 +248,7 @@ class PlPlayerController {
|
||||
late double showArea;
|
||||
late double opacityVal;
|
||||
late double fontSizeVal;
|
||||
late double fontSizeFSVal;
|
||||
late double strokeWidth;
|
||||
late int fontWeight;
|
||||
late double danmakuDurationVal;
|
||||
@@ -348,6 +349,8 @@ class PlPlayerController {
|
||||
// 字体大小
|
||||
fontSizeVal =
|
||||
setting.get(SettingBoxKey.danmakuFontScale, defaultValue: 1.0);
|
||||
// 全屏字体大小
|
||||
fontSizeFSVal = GStorage.danmakuFontScaleFS;
|
||||
// 弹幕时间
|
||||
danmakuDurationVal =
|
||||
setting.get(SettingBoxKey.danmakuDuration, defaultValue: 7.29);
|
||||
@@ -1281,6 +1284,7 @@ class PlPlayerController {
|
||||
setting.put(SettingBoxKey.danmakuShowArea, showArea);
|
||||
setting.put(SettingBoxKey.danmakuOpacity, opacityVal);
|
||||
setting.put(SettingBoxKey.danmakuFontScale, fontSizeVal);
|
||||
setting.put(SettingBoxKey.danmakuFontScaleFS, fontSizeFSVal);
|
||||
setting.put(SettingBoxKey.danmakuDuration, danmakuDurationVal);
|
||||
setting.put(SettingBoxKey.strokeWidth, strokeWidth);
|
||||
setting.put(SettingBoxKey.fontWeight, fontWeight);
|
||||
|
||||
@@ -96,6 +96,9 @@ class GStorage {
|
||||
static int get schemeVariant =>
|
||||
setting.get(SettingBoxKey.schemeVariant, defaultValue: 0);
|
||||
|
||||
static double get danmakuFontScaleFS =>
|
||||
setting.get(SettingBoxKey.danmakuFontScaleFS, defaultValue: 1.2);
|
||||
|
||||
static MemberTabType get memberTab => MemberTabType
|
||||
.values[setting.get(SettingBoxKey.memberTab, defaultValue: 0)];
|
||||
|
||||
@@ -292,6 +295,7 @@ class SettingBoxKey {
|
||||
danmakuShowArea = 'danmakuShowArea',
|
||||
danmakuOpacity = 'danmakuOpacity',
|
||||
danmakuFontScale = 'danmakuFontScale',
|
||||
danmakuFontScaleFS = 'danmakuFontScaleFS',
|
||||
danmakuDuration = 'danmakuDuration',
|
||||
strokeWidth = 'strokeWidth',
|
||||
fontWeight = 'fontWeight',
|
||||
|
||||
Reference in New Issue
Block a user