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;
|
// bool danmuPlayStatus = true;
|
||||||
Box setting = GStorage.setting;
|
Box setting = GStorage.setting;
|
||||||
late bool enableShowDanmaku;
|
late bool enableShowDanmaku;
|
||||||
late List blockTypes;
|
// late List blockTypes;
|
||||||
late double showArea;
|
// late double showArea;
|
||||||
late double opacityVal;
|
// late double opacityVal;
|
||||||
late double fontSizeVal;
|
// late double fontSizeVal;
|
||||||
late double danmakuDurationVal;
|
// late double fontSizeFSVal;
|
||||||
late double strokeWidth;
|
// late double danmakuDurationVal;
|
||||||
late int fontWeight;
|
// late double strokeWidth;
|
||||||
|
// late int fontWeight;
|
||||||
int latestAddedPosition = -1;
|
int latestAddedPosition = -1;
|
||||||
bool showDanmaku = true;
|
bool showDanmaku = true;
|
||||||
bool? _isFullScreen;
|
bool? _isFullScreen;
|
||||||
@@ -94,13 +95,14 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
blockTypes = playerController.blockTypes;
|
// blockTypes = playerController.blockTypes;
|
||||||
showArea = playerController.showArea;
|
// showArea = playerController.showArea;
|
||||||
opacityVal = playerController.opacityVal;
|
// opacityVal = playerController.opacityVal;
|
||||||
fontSizeVal = playerController.fontSizeVal;
|
// fontSizeVal = playerController.fontSizeVal;
|
||||||
strokeWidth = playerController.strokeWidth;
|
// fontSizeFSVal = playerController.fontSizeFSVal;
|
||||||
fontWeight = playerController.fontWeight;
|
// strokeWidth = playerController.strokeWidth;
|
||||||
danmakuDurationVal = playerController.danmakuDurationVal;
|
// fontWeight = playerController.fontWeight;
|
||||||
|
// danmakuDurationVal = playerController.danmakuDurationVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 播放器状态监听
|
// 播放器状态监听
|
||||||
@@ -157,8 +159,8 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
|||||||
|
|
||||||
double _getFontSize(isFullScreen) =>
|
double _getFontSize(isFullScreen) =>
|
||||||
isFullScreen == false || widget.isPipMode == true
|
isFullScreen == false || widget.isPipMode == true
|
||||||
? 15 * fontSizeVal
|
? 15 * playerController.fontSizeVal
|
||||||
: 15 * fontSizeVal * 1.2;
|
: 15 * playerController.fontSizeFSVal;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -174,14 +176,15 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
|||||||
},
|
},
|
||||||
option: DanmakuOption(
|
option: DanmakuOption(
|
||||||
fontSize: _getFontSize(playerController.isFullScreen.value),
|
fontSize: _getFontSize(playerController.isFullScreen.value),
|
||||||
fontWeight: fontWeight,
|
fontWeight: playerController.fontWeight,
|
||||||
area: showArea,
|
area: playerController.showArea,
|
||||||
opacity: opacityVal,
|
opacity: playerController.opacityVal,
|
||||||
hideTop: blockTypes.contains(5),
|
hideTop: playerController.blockTypes.contains(5),
|
||||||
hideScroll: blockTypes.contains(2),
|
hideScroll: playerController.blockTypes.contains(2),
|
||||||
hideBottom: blockTypes.contains(4),
|
hideBottom: playerController.blockTypes.contains(4),
|
||||||
duration: danmakuDurationVal / playerController.playbackSpeed,
|
duration: playerController.danmakuDurationVal /
|
||||||
strokeWidth: strokeWidth,
|
playerController.playbackSpeed,
|
||||||
|
strokeWidth: playerController.strokeWidth,
|
||||||
// initDuration /
|
// initDuration /
|
||||||
// (danmakuSpeedVal * widget.playerController.playbackSpeed),
|
// (danmakuSpeedVal * widget.playerController.playbackSpeed),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -42,14 +42,15 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
late final _node = FocusNode();
|
late final _node = FocusNode();
|
||||||
late final _ctr = TextEditingController();
|
late final _ctr = TextEditingController();
|
||||||
|
|
||||||
late bool enableShowDanmaku;
|
// late bool enableShowDanmaku;
|
||||||
late List blockTypes;
|
// late List blockTypes;
|
||||||
late double showArea;
|
// late double showArea;
|
||||||
late double opacityVal;
|
// late double opacityVal;
|
||||||
late double fontSizeVal;
|
// late double fontSizeVal;
|
||||||
late double danmakuDurationVal;
|
// late double fontSizeFSVal;
|
||||||
late double strokeWidth;
|
// late double danmakuDurationVal;
|
||||||
late int fontWeight;
|
// late double strokeWidth;
|
||||||
|
// late int fontWeight;
|
||||||
int latestAddedPosition = -1;
|
int latestAddedPosition = -1;
|
||||||
bool? _isFullScreen;
|
bool? _isFullScreen;
|
||||||
bool? _isPipMode;
|
bool? _isPipMode;
|
||||||
@@ -93,20 +94,21 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
|
|
||||||
double _getFontSize(isFullScreen) {
|
double _getFontSize(isFullScreen) {
|
||||||
return isFullScreen == false || _isPipMode != false
|
return isFullScreen == false || _isPipMode != false
|
||||||
? 15 * fontSizeVal
|
? 15 * plPlayerController.fontSizeVal
|
||||||
: 15 * fontSizeVal * 1.2;
|
: 15 * plPlayerController.fontSizeFSVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> videoSourceInit() async {
|
Future<void> videoSourceInit() async {
|
||||||
_futureBuilder = _liveRoomController.queryLiveInfoH5();
|
_futureBuilder = _liveRoomController.queryLiveInfoH5();
|
||||||
plPlayerController = _liveRoomController.plPlayerController;
|
plPlayerController = _liveRoomController.plPlayerController;
|
||||||
blockTypes = plPlayerController.blockTypes;
|
// blockTypes = plPlayerController.blockTypes;
|
||||||
showArea = plPlayerController.showArea;
|
// showArea = plPlayerController.showArea;
|
||||||
opacityVal = plPlayerController.opacityVal;
|
// opacityVal = plPlayerController.opacityVal;
|
||||||
fontSizeVal = plPlayerController.fontSizeVal;
|
// fontSizeVal = plPlayerController.fontSizeVal;
|
||||||
strokeWidth = plPlayerController.strokeWidth;
|
// fontSizeFSVal = plPlayerController.fontSizeFSVal;
|
||||||
fontWeight = plPlayerController.fontWeight;
|
// strokeWidth = plPlayerController.strokeWidth;
|
||||||
danmakuDurationVal = plPlayerController.danmakuDurationVal;
|
// fontWeight = plPlayerController.fontWeight;
|
||||||
|
// danmakuDurationVal = plPlayerController.danmakuDurationVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -157,15 +159,15 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
option: DanmakuOption(
|
option: DanmakuOption(
|
||||||
fontSize:
|
fontSize:
|
||||||
_getFontSize(plPlayerController.isFullScreen.value),
|
_getFontSize(plPlayerController.isFullScreen.value),
|
||||||
fontWeight: fontWeight,
|
fontWeight: plPlayerController.fontWeight,
|
||||||
area: showArea,
|
area: plPlayerController.showArea,
|
||||||
opacity: opacityVal,
|
opacity: plPlayerController.opacityVal,
|
||||||
hideTop: blockTypes.contains(5),
|
hideTop: plPlayerController.blockTypes.contains(5),
|
||||||
hideScroll: blockTypes.contains(2),
|
hideScroll: plPlayerController.blockTypes.contains(2),
|
||||||
hideBottom: blockTypes.contains(4),
|
hideBottom: plPlayerController.blockTypes.contains(4),
|
||||||
duration:
|
duration: plPlayerController.danmakuDurationVal /
|
||||||
danmakuDurationVal / plPlayerController.playbackSpeed,
|
plPlayerController.playbackSpeed,
|
||||||
strokeWidth: strokeWidth,
|
strokeWidth: plPlayerController.strokeWidth,
|
||||||
// initDuration /
|
// initDuration /
|
||||||
// (danmakuSpeedVal * widget.playerController.playbackSpeed),
|
// (danmakuSpeedVal * widget.playerController.playbackSpeed),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -892,6 +892,8 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
double opacityVal = widget.controller!.opacityVal;
|
double opacityVal = widget.controller!.opacityVal;
|
||||||
// 字体大小
|
// 字体大小
|
||||||
double fontSizeVal = widget.controller!.fontSizeVal;
|
double fontSizeVal = widget.controller!.fontSizeVal;
|
||||||
|
// 全屏字体大小
|
||||||
|
double fontSizeFSVal = widget.controller!.fontSizeFSVal;
|
||||||
// 弹幕速度
|
// 弹幕速度
|
||||||
double danmakuDurationVal = widget.controller!.danmakuDurationVal;
|
double danmakuDurationVal = widget.controller!.danmakuDurationVal;
|
||||||
// 弹幕描边
|
// 弹幕描边
|
||||||
@@ -1198,15 +1200,60 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
widget.controller!.fontSizeVal = fontSizeVal;
|
widget.controller!.fontSizeVal = fontSizeVal;
|
||||||
widget.controller?.putDanmakuSettings();
|
widget.controller?.putDanmakuSettings();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
try {
|
if (widget.controller?.isFullScreen.value == false) {
|
||||||
final DanmakuOption currentOption =
|
try {
|
||||||
danmakuController.option;
|
final DanmakuOption currentOption =
|
||||||
final DanmakuOption updatedOption =
|
danmakuController.option;
|
||||||
currentOption.copyWith(
|
final DanmakuOption updatedOption =
|
||||||
fontSize: (15 * fontSizeVal).toDouble(),
|
currentOption.copyWith(
|
||||||
);
|
fontSize: (15 * fontSizeVal).toDouble(),
|
||||||
danmakuController.updateOption(updatedOption);
|
);
|
||||||
} catch (_) {}
|
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 showArea;
|
||||||
late double opacityVal;
|
late double opacityVal;
|
||||||
late double fontSizeVal;
|
late double fontSizeVal;
|
||||||
|
late double fontSizeFSVal;
|
||||||
late double strokeWidth;
|
late double strokeWidth;
|
||||||
late int fontWeight;
|
late int fontWeight;
|
||||||
late double danmakuDurationVal;
|
late double danmakuDurationVal;
|
||||||
@@ -348,6 +349,8 @@ class PlPlayerController {
|
|||||||
// 字体大小
|
// 字体大小
|
||||||
fontSizeVal =
|
fontSizeVal =
|
||||||
setting.get(SettingBoxKey.danmakuFontScale, defaultValue: 1.0);
|
setting.get(SettingBoxKey.danmakuFontScale, defaultValue: 1.0);
|
||||||
|
// 全屏字体大小
|
||||||
|
fontSizeFSVal = GStorage.danmakuFontScaleFS;
|
||||||
// 弹幕时间
|
// 弹幕时间
|
||||||
danmakuDurationVal =
|
danmakuDurationVal =
|
||||||
setting.get(SettingBoxKey.danmakuDuration, defaultValue: 7.29);
|
setting.get(SettingBoxKey.danmakuDuration, defaultValue: 7.29);
|
||||||
@@ -1281,6 +1284,7 @@ class PlPlayerController {
|
|||||||
setting.put(SettingBoxKey.danmakuShowArea, showArea);
|
setting.put(SettingBoxKey.danmakuShowArea, showArea);
|
||||||
setting.put(SettingBoxKey.danmakuOpacity, opacityVal);
|
setting.put(SettingBoxKey.danmakuOpacity, opacityVal);
|
||||||
setting.put(SettingBoxKey.danmakuFontScale, fontSizeVal);
|
setting.put(SettingBoxKey.danmakuFontScale, fontSizeVal);
|
||||||
|
setting.put(SettingBoxKey.danmakuFontScaleFS, fontSizeFSVal);
|
||||||
setting.put(SettingBoxKey.danmakuDuration, danmakuDurationVal);
|
setting.put(SettingBoxKey.danmakuDuration, danmakuDurationVal);
|
||||||
setting.put(SettingBoxKey.strokeWidth, strokeWidth);
|
setting.put(SettingBoxKey.strokeWidth, strokeWidth);
|
||||||
setting.put(SettingBoxKey.fontWeight, fontWeight);
|
setting.put(SettingBoxKey.fontWeight, fontWeight);
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ class GStorage {
|
|||||||
static int get schemeVariant =>
|
static int get schemeVariant =>
|
||||||
setting.get(SettingBoxKey.schemeVariant, defaultValue: 0);
|
setting.get(SettingBoxKey.schemeVariant, defaultValue: 0);
|
||||||
|
|
||||||
|
static double get danmakuFontScaleFS =>
|
||||||
|
setting.get(SettingBoxKey.danmakuFontScaleFS, defaultValue: 1.2);
|
||||||
|
|
||||||
static MemberTabType get memberTab => MemberTabType
|
static MemberTabType get memberTab => MemberTabType
|
||||||
.values[setting.get(SettingBoxKey.memberTab, defaultValue: 0)];
|
.values[setting.get(SettingBoxKey.memberTab, defaultValue: 0)];
|
||||||
|
|
||||||
@@ -292,6 +295,7 @@ class SettingBoxKey {
|
|||||||
danmakuShowArea = 'danmakuShowArea',
|
danmakuShowArea = 'danmakuShowArea',
|
||||||
danmakuOpacity = 'danmakuOpacity',
|
danmakuOpacity = 'danmakuOpacity',
|
||||||
danmakuFontScale = 'danmakuFontScale',
|
danmakuFontScale = 'danmakuFontScale',
|
||||||
|
danmakuFontScaleFS = 'danmakuFontScaleFS',
|
||||||
danmakuDuration = 'danmakuDuration',
|
danmakuDuration = 'danmakuDuration',
|
||||||
strokeWidth = 'strokeWidth',
|
strokeWidth = 'strokeWidth',
|
||||||
fontWeight = 'fontWeight',
|
fontWeight = 'fontWeight',
|
||||||
|
|||||||
Reference in New Issue
Block a user