From 5f299d92329242e187d466a4de6cb768de5b1570 Mon Sep 17 00:00:00 2001 From: orz12 Date: Thu, 25 Jan 2024 11:36:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=BC=B9=E5=B9=95?= =?UTF-8?q?=E6=8F=8F=E8=BE=B9=E7=B2=97=E7=BB=86=E8=AE=BE=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=E9=99=8D=E4=BD=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/danmaku/view.dart | 3 ++ .../video/detail/widgets/header_control.dart | 41 +++++++++++++++++++ lib/plugin/pl_player/controller.dart | 5 +++ lib/utils/storage.dart | 3 +- 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/lib/pages/danmaku/view.dart b/lib/pages/danmaku/view.dart index 83d6020ee..109f02066 100644 --- a/lib/pages/danmaku/view.dart +++ b/lib/pages/danmaku/view.dart @@ -35,6 +35,7 @@ class _PlDanmakuState extends State { late double opacityVal; late double fontSizeVal; late double danmakuDurationVal; + late double strokeWidth; int latestAddedPosition = -1; @override @@ -65,6 +66,7 @@ class _PlDanmakuState extends State { showArea = playerController.showArea; opacityVal = playerController.opacityVal; fontSizeVal = playerController.fontSizeVal; + strokeWidth = playerController.strokeWidth; danmakuDurationVal = playerController.danmakuDurationVal; } @@ -136,6 +138,7 @@ class _PlDanmakuState extends State { hideBottom: blockTypes.contains(4), duration: danmakuDurationVal / playerController.playbackSpeed, + strokeWidth: strokeWidth, // initDuration / // (danmakuSpeedVal * widget.playerController.playbackSpeed), ), diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index f2e38870b..3af35efdb 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'dart:math'; import 'package:floating/floating.dart'; import 'package:flutter/material.dart'; @@ -724,6 +725,8 @@ class _HeaderControlState extends State { double fontSizeVal = widget.controller!.fontSizeVal; // 弹幕速度 double danmakuDurationVal = widget.controller!.danmakuDurationVal; + // 弹幕描边 + double strokeWidth = widget.controller!.strokeWidth; final DanmakuController danmakuController = widget.controller!.danmakuController!; @@ -857,6 +860,44 @@ class _HeaderControlState extends State { ), ), ), + Text('描边粗细 $strokeWidth'), + 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, + max: 3, + value: strokeWidth, + divisions: 6, + label: '$strokeWidth', + onChanged: (double val) { + strokeWidth = val; + widget.controller!.strokeWidth = val; + setState(() {}); + try { + final DanmakuOption currentOption = + danmakuController.option; + final DanmakuOption updatedOption = + currentOption.copyWith(strokeWidth: val); + danmakuController.updateOption(updatedOption); + } catch (_) {} + }, + ), + ), + ), Text('字体大小 ${(fontSizeVal * 100).toStringAsFixed(1)}%'), Padding( padding: const EdgeInsets.only( diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 5fd10406a..f7b0c7e22 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -222,6 +222,7 @@ class PlPlayerController { late double showArea; late double opacityVal; late double fontSizeVal; + late double strokeWidth; late double danmakuDurationVal; late List speedsList; // 缓存 @@ -276,6 +277,9 @@ class PlPlayerController { // 弹幕时间 danmakuDurationVal = localCache.get(LocalCacheKey.danmakuDuration, defaultValue: 4.0); + // 描边粗细 + strokeWidth = + localCache.get(LocalCacheKey.strokeWidth, defaultValue: 1.5); playRepeat = PlayRepeat.values.toList().firstWhere( (e) => e.value == @@ -1087,6 +1091,7 @@ class PlPlayerController { localCache.put(LocalCacheKey.danmakuOpacity, opacityVal); localCache.put(LocalCacheKey.danmakuFontScale, fontSizeVal); localCache.put(LocalCacheKey.danmakuDuration, danmakuDurationVal); + localCache.put(LocalCacheKey.strokeWidth, strokeWidth); if (_videoPlayerController != null) { var pp = _videoPlayerController!.platform as NativePlayer; await pp.setProperty('audio-files', ''); diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index a4cc07710..e5b03030a 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -166,12 +166,13 @@ class LocalCacheKey { wbiKeys = 'wbiKeys', timeStamp = 'timeStamp', - // 弹幕相关设置 屏蔽类型 显示区域 透明度 字体大小 弹幕时间 + // 弹幕相关设置 屏蔽类型 显示区域 透明度 字体大小 弹幕时间 描边粗细 danmakuBlockType = 'danmakuBlockType', danmakuShowArea = 'danmakuShowArea', danmakuOpacity = 'danmakuOpacity', danmakuFontScale = 'danmakuFontScale', danmakuDuration = 'danmakuDuration', + strokeWidth = 'strokeWidth', // 代理host port systemProxyHost = 'systemProxyHost',