diff --git a/lib/pages/danmaku/view.dart b/lib/pages/danmaku/view.dart index d19e31684..224525754 100644 --- a/lib/pages/danmaku/view.dart +++ b/lib/pages/danmaku/view.dart @@ -138,8 +138,8 @@ class _PlDanmakuState extends State { double _getFontSize(isFullScreen) => isFullScreen == false || widget.isPipMode == true - ? 15 * playerController.fontSizeVal - : 15 * playerController.fontSizeFSVal; + ? 15 * playerController.fontSize + : 15 * playerController.fontSizeFS; @override Widget build(BuildContext context) { @@ -157,11 +157,13 @@ class _PlDanmakuState extends State { fontSize: _getFontSize(playerController.isFullScreen.value), fontWeight: playerController.fontWeight, area: playerController.showArea, - opacity: playerController.opacityVal, + opacity: playerController.opacity, hideTop: playerController.blockTypes.contains(5), hideScroll: playerController.blockTypes.contains(2), hideBottom: playerController.blockTypes.contains(4), - duration: playerController.danmakuDurationVal ~/ + duration: playerController.danmakuDuration ~/ + playerController.playbackSpeed, + staticDuration: playerController.danmakuStaticDuration ~/ playerController.playbackSpeed, strokeWidth: playerController.strokeWidth, lineHeight: playerController.danmakuLineHeight, diff --git a/lib/pages/live_room/view.dart b/lib/pages/live_room/view.dart index 567acdc9e..812db8e76 100644 --- a/lib/pages/live_room/view.dart +++ b/lib/pages/live_room/view.dart @@ -96,8 +96,8 @@ class _LiveRoomPageState extends State double _getFontSize(isFullScreen) { return isFullScreen == false || _isPipMode == true - ? 15 * plPlayerController.fontSizeVal - : 15 * plPlayerController.fontSizeFSVal; + ? 15 * plPlayerController.fontSize + : 15 * plPlayerController.fontSizeFS; } void videoSourceInit() { @@ -176,12 +176,15 @@ class _LiveRoomPageState extends State fontSize: _getFontSize(isFullScreen), fontWeight: plPlayerController.fontWeight, area: plPlayerController.showArea, - opacity: plPlayerController.opacityVal, + opacity: plPlayerController.opacity, hideTop: plPlayerController.blockTypes.contains(5), hideScroll: plPlayerController.blockTypes.contains(2), hideBottom: plPlayerController.blockTypes.contains(4), - duration: plPlayerController.danmakuDurationVal ~/ + duration: plPlayerController.danmakuDuration ~/ plPlayerController.playbackSpeed, + staticDuration: + plPlayerController.danmakuStaticDuration ~/ + plPlayerController.playbackSpeed, strokeWidth: plPlayerController.strokeWidth, lineHeight: plPlayerController.danmakuLineHeight, ), diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 5acc43df6..a22476046 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -1453,14 +1453,15 @@ class _HeaderControlState extends State { // 显示区域 double showArea = widget.controller.showArea; // 不透明度 - double opacityVal = widget.controller.opacityVal; + double opacity = widget.controller.opacity; // 字体大小 - double fontSizeVal = widget.controller.fontSizeVal; + double fontSize = widget.controller.fontSize; // 全屏字体大小 - double fontSizeFSVal = widget.controller.fontSizeFSVal; + double fontSizeFS = widget.controller.fontSizeFS; double danmakuLineHeight = widget.controller.danmakuLineHeight; // 弹幕速度 - double danmakuDurationVal = widget.controller.danmakuDurationVal; + double danmakuDuration = widget.controller.danmakuDuration; + double danmakuStaticDuration = widget.controller.danmakuStaticDuration; // 弹幕描边 double strokeWidth = widget.controller.strokeWidth; // 字体粗细 @@ -1499,31 +1500,46 @@ class _HeaderControlState extends State { } void updateDuration(double val) { - danmakuDurationVal = val; + danmakuDuration = val; widget.controller - ..danmakuDurationVal = danmakuDurationVal + ..danmakuDuration = danmakuDuration ..putDanmakuSettings(); setState(() {}); try { danmakuController?.updateOption( danmakuController.option.copyWith( duration: - danmakuDurationVal ~/ widget.controller.playbackSpeed), + danmakuDuration ~/ widget.controller.playbackSpeed), + ); + } catch (_) {} + } + + void updateStaticDuration(double val) { + danmakuStaticDuration = val; + widget.controller + ..danmakuStaticDuration = danmakuStaticDuration + ..putDanmakuSettings(); + setState(() {}); + try { + danmakuController?.updateOption( + danmakuController.option.copyWith( + staticDuration: danmakuStaticDuration ~/ + widget.controller.playbackSpeed), ); } catch (_) {} } void updateFontSizeFS(double val) { - fontSizeFSVal = val; + fontSizeFS = val; widget.controller - ..fontSizeFSVal = fontSizeFSVal + ..fontSizeFS = fontSizeFS ..putDanmakuSettings(); setState(() {}); if (widget.controller.isFullScreen.value == true) { try { danmakuController?.updateOption( danmakuController.option.copyWith( - fontSize: (15 * fontSizeFSVal).toDouble(), + fontSize: (15 * fontSizeFS).toDouble(), ), ); } catch (_) {} @@ -1531,16 +1547,16 @@ class _HeaderControlState extends State { } void updateFontSize(double val) { - fontSizeVal = val; + fontSize = val; widget.controller - ..fontSizeVal = fontSizeVal + ..fontSize = fontSize ..putDanmakuSettings(); setState(() {}); if (widget.controller.isFullScreen.value == false) { try { danmakuController?.updateOption( danmakuController.option.copyWith( - fontSize: (15 * fontSizeVal).toDouble(), + fontSize: (15 * fontSize).toDouble(), ), ); } catch (_) {} @@ -1574,9 +1590,9 @@ class _HeaderControlState extends State { } void updateOpacity(double val) { - opacityVal = val; + opacity = val; widget.controller - ..opacityVal = opacityVal + ..opacity = opacity ..putDanmakuSettings(); setState(() {}); try { @@ -1751,7 +1767,7 @@ class _HeaderControlState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('不透明度 ${opacityVal * 100}%'), + Text('不透明度 ${opacity * 100}%'), resetBtn('100.0%', () => updateOpacity(1.0)), ], ), @@ -1767,9 +1783,9 @@ class _HeaderControlState extends State { child: Slider( min: 0, max: 1, - value: opacityVal, + value: opacity, divisions: 10, - label: '${opacityVal * 100}%', + label: '${opacity * 100}%', onChanged: updateOpacity, ), ), @@ -1831,7 +1847,7 @@ class _HeaderControlState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('字体大小 ${(fontSizeVal * 100).toStringAsFixed(1)}%'), + Text('字体大小 ${(fontSize * 100).toStringAsFixed(1)}%'), resetBtn('100.0%', () => updateFontSize(1.0)), ], ), @@ -1847,9 +1863,9 @@ class _HeaderControlState extends State { child: Slider( min: 0.5, max: 2.5, - value: fontSizeVal, + value: fontSize, divisions: 20, - label: '${(fontSizeVal * 100).toStringAsFixed(1)}%', + label: '${(fontSize * 100).toStringAsFixed(1)}%', onChanged: updateFontSize, ), ), @@ -1858,7 +1874,7 @@ class _HeaderControlState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '全屏字体大小 ${(fontSizeFSVal * 100).toStringAsFixed(1)}%'), + '全屏字体大小 ${(fontSizeFS * 100).toStringAsFixed(1)}%'), resetBtn('120.0%', () => updateFontSizeFS(1.2)), ], ), @@ -1874,9 +1890,9 @@ class _HeaderControlState extends State { child: Slider( min: 0.5, max: 2.5, - value: fontSizeFSVal, + value: fontSizeFS, divisions: 20, - label: '${(fontSizeFSVal * 100).toStringAsFixed(1)}%', + label: '${(fontSizeFS * 100).toStringAsFixed(1)}%', onChanged: updateFontSizeFS, ), ), @@ -1884,7 +1900,7 @@ class _HeaderControlState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('弹幕时长 $danmakuDurationVal 秒'), + Text('滚动弹幕时长 $danmakuDuration 秒'), resetBtn(7.0, () => updateDuration(7.0)), ], ), @@ -1900,15 +1916,43 @@ class _HeaderControlState extends State { child: Slider( min: 1, max: 50, - value: danmakuDurationVal, + value: danmakuDuration, divisions: 49, - label: danmakuDurationVal.toString(), + label: danmakuDuration.toString(), onChanged: (double val) { updateDuration(val.toPrecision(1)); }, ), ), ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('静态弹幕时长 $danmakuStaticDuration 秒'), + resetBtn(4.0, () => updateStaticDuration(4.0)), + ], + ), + Padding( + padding: const EdgeInsets.only( + top: 0, + bottom: 6, + left: 10, + right: 10, + ), + child: SliderTheme( + data: sliderTheme, + child: Slider( + min: 1, + max: 50, + value: danmakuStaticDuration, + divisions: 49, + label: danmakuStaticDuration.toString(), + onChanged: (double val) { + updateStaticDuration(val.toPrecision(1)); + }, + ), + ), + ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index dfd2b3340..0d108f7fa 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -270,13 +270,14 @@ class PlPlayerController { // 弹幕相关配置 late List blockTypes; late double showArea; - late double opacityVal; - late double fontSizeVal; - late double fontSizeFSVal; + late double opacity; + late double fontSize; + late double fontSizeFS; late double strokeWidth; late int fontWeight; late bool massiveMode; - late double danmakuDurationVal; + late double danmakuDuration; + late double danmakuStaticDuration; late List speedList; double? defaultDuration; late bool enableAutoLongPressSpeed = false; @@ -409,18 +410,19 @@ class PlPlayerController { blockTypes = setting.get(SettingBoxKey.danmakuBlockType, defaultValue: []); showArea = setting.get(SettingBoxKey.danmakuShowArea, defaultValue: 0.5); // 不透明度 - opacityVal = setting.get(SettingBoxKey.danmakuOpacity, defaultValue: 1.0); + opacity = setting.get(SettingBoxKey.danmakuOpacity, defaultValue: 1.0); // 字体大小 - fontSizeVal = - setting.get(SettingBoxKey.danmakuFontScale, defaultValue: 1.0); + fontSize = setting.get(SettingBoxKey.danmakuFontScale, defaultValue: 1.0); // 全屏字体大小 - fontSizeFSVal = GStorage.danmakuFontScaleFS; + fontSizeFS = GStorage.danmakuFontScaleFS; subtitleFontScale = GStorage.subtitleFontScale; subtitleFontScaleFS = GStorage.subtitleFontScaleFS; massiveMode = GStorage.danmakuMassiveMode; // 弹幕时间 - danmakuDurationVal = + danmakuDuration = setting.get(SettingBoxKey.danmakuDuration, defaultValue: 7.0); + danmakuStaticDuration = + setting.get(SettingBoxKey.danmakuStaticDuration, defaultValue: 4.0); // 描边粗细 strokeWidth = setting.get(SettingBoxKey.strokeWidth, defaultValue: 1.5); // 弹幕字体粗细 @@ -1509,10 +1511,11 @@ class PlPlayerController { setting.put(SettingBoxKey.danmakuWeight, danmakuWeight); setting.put(SettingBoxKey.danmakuBlockType, blockTypes); 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.danmakuOpacity, opacity); + setting.put(SettingBoxKey.danmakuFontScale, fontSize); + setting.put(SettingBoxKey.danmakuFontScaleFS, fontSizeFS); + setting.put(SettingBoxKey.danmakuDuration, danmakuDuration); + setting.put(SettingBoxKey.danmakuStaticDuration, danmakuStaticDuration); setting.put(SettingBoxKey.strokeWidth, strokeWidth); setting.put(SettingBoxKey.fontWeight, fontWeight); setting.put(SettingBoxKey.danmakuLineHeight, danmakuLineHeight); diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index d7c51896a..50fad0812 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -741,6 +741,7 @@ class SettingBoxKey { danmakuFontScale = 'danmakuFontScale', danmakuFontScaleFS = 'danmakuFontScaleFS', danmakuDuration = 'danmakuDuration', + danmakuStaticDuration = 'danmakuStaticDuration', danmakuMassiveMode = 'danmakuMassiveMode', danmakuLineHeight = 'danmakuLineHeight', strokeWidth = 'strokeWidth', diff --git a/pubspec.lock b/pubspec.lock index 1c0112dd3..28ba17ef4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -252,7 +252,7 @@ packages: description: path: "." ref: main - resolved-ref: "4fb1d2d15fa84d28aae45aa2324beb7f230c045c" + resolved-ref: "5391050a7e070a85234762edadc93298c6ed6523" url: "https://github.com/bggRGjQaUbCoE/canvas_danmaku.git" source: git version: "0.2.6"