mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom subtitle fontscale
Closes #28 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -258,6 +258,8 @@ class PlPlayerController {
|
||||
double? defaultDuration;
|
||||
late bool enableAutoLongPressSpeed = false;
|
||||
late bool enableLongShowControl;
|
||||
RxDouble subtitleFontScale = (1.0).obs;
|
||||
RxDouble subtitleFontScaleFS = (1.5).obs;
|
||||
|
||||
// 播放顺序相关
|
||||
PlayRepeat playRepeat = PlayRepeat.pause;
|
||||
@@ -351,6 +353,8 @@ class PlPlayerController {
|
||||
setting.get(SettingBoxKey.danmakuFontScale, defaultValue: 1.0);
|
||||
// 全屏字体大小
|
||||
fontSizeFSVal = GStorage.danmakuFontScaleFS;
|
||||
subtitleFontScale.value = GStorage.subtitleFontScale;
|
||||
subtitleFontScaleFS.value = GStorage.subtitleFontScaleFS;
|
||||
// 弹幕时间
|
||||
danmakuDurationVal =
|
||||
setting.get(SettingBoxKey.danmakuDuration, defaultValue: 7.29);
|
||||
@@ -1296,6 +1300,8 @@ class PlPlayerController {
|
||||
setting.put(SettingBoxKey.danmakuOpacity, opacityVal);
|
||||
setting.put(SettingBoxKey.danmakuFontScale, fontSizeVal);
|
||||
setting.put(SettingBoxKey.danmakuFontScaleFS, fontSizeFSVal);
|
||||
setting.put(SettingBoxKey.subtitleFontScale, subtitleFontScale.value);
|
||||
setting.put(SettingBoxKey.subtitleFontScaleFS, subtitleFontScaleFS.value);
|
||||
setting.put(SettingBoxKey.danmakuDuration, danmakuDurationVal);
|
||||
setting.put(SettingBoxKey.strokeWidth, strokeWidth);
|
||||
setting.put(SettingBoxKey.fontWeight, fontWeight);
|
||||
|
||||
@@ -75,6 +75,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
late BangumiIntroController? bangumiIntroController;
|
||||
|
||||
final GlobalKey _playerKey = GlobalKey();
|
||||
final GlobalKey<VideoState> _key = GlobalKey<VideoState>();
|
||||
|
||||
final RxBool _mountSeekBackwardButton = false.obs;
|
||||
final RxBool _mountSeekForwardButton = false.obs;
|
||||
final RxBool _hideSeekBackwardButton = false.obs;
|
||||
@@ -529,19 +531,43 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
return list;
|
||||
}
|
||||
|
||||
PlPlayerController get plPlayerController => widget.controller;
|
||||
|
||||
TextStyle get subTitleStyle => TextStyle(
|
||||
height: 1.5,
|
||||
fontSize: 16 *
|
||||
(plPlayerController.isFullScreen.value
|
||||
? plPlayerController.subtitleFontScaleFS.value
|
||||
: plPlayerController.subtitleFontScale.value),
|
||||
letterSpacing: 0.1,
|
||||
wordSpacing: 0.1,
|
||||
color: Color(0xffffffff),
|
||||
fontWeight: FontWeight.normal,
|
||||
backgroundColor: Color(0xaa000000),
|
||||
);
|
||||
|
||||
void _updateSubtitle(double value) {
|
||||
_key.currentState?.update(
|
||||
subtitleViewConfiguration: SubtitleViewConfiguration(
|
||||
style: subTitleStyle.copyWith(fontSize: 16 * value),
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
textScaleFactor: MediaQuery.textScalerOf(context).scale(1),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final PlPlayerController plPlayerController = widget.controller;
|
||||
if (plPlayerController.isFullScreen.value) {
|
||||
plPlayerController.subtitleFontScaleFS.listen((value) {
|
||||
_updateSubtitle(value);
|
||||
});
|
||||
} else {
|
||||
plPlayerController.subtitleFontScale.listen((value) {
|
||||
_updateSubtitle(value);
|
||||
});
|
||||
}
|
||||
final Color colorTheme = Theme.of(context).colorScheme.primary;
|
||||
const TextStyle subTitleStyle = TextStyle(
|
||||
height: 1.5,
|
||||
fontSize: 20.0,
|
||||
letterSpacing: 0.1,
|
||||
wordSpacing: 0.1,
|
||||
color: Color(0xffffffff),
|
||||
fontWeight: FontWeight.normal,
|
||||
backgroundColor: Color(0xaa000000),
|
||||
);
|
||||
const TextStyle textStyle = TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
@@ -684,7 +710,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
_gestureType = null;
|
||||
},
|
||||
child: Video(
|
||||
key: ValueKey('${plPlayerController.videoFit.value}'),
|
||||
key: _key,
|
||||
controller: videoController,
|
||||
controls: NoVideoControls,
|
||||
pauseUponEnteringBackgroundMode:
|
||||
|
||||
Reference in New Issue
Block a user