refactor: GlobalDataCache
This commit is contained in:
@ -278,19 +278,18 @@ class PlPlayerController {
|
||||
|
||||
// 添加一个私有构造函数
|
||||
PlPlayerController._internal(this.videoType) {
|
||||
final cache = GlobalDataCache();
|
||||
isOpenDanmu.value = cache.isOpenDanmu;
|
||||
blockTypes = cache.blockTypes;
|
||||
showArea = cache.showArea;
|
||||
opacityVal = cache.opacityVal;
|
||||
fontSizeVal = cache.fontSizeVal;
|
||||
danmakuDurationVal = cache.danmakuDurationVal;
|
||||
strokeWidth = cache.strokeWidth;
|
||||
playRepeat = cache.playRepeat;
|
||||
_playbackSpeed.value = cache.playbackSpeed;
|
||||
enableAutoLongPressSpeed = cache.enableAutoLongPressSpeed;
|
||||
_longPressSpeed.value = cache.longPressSpeed;
|
||||
speedsList = cache.speedsList;
|
||||
isOpenDanmu.value = GlobalDataCache.isOpenDanmu;
|
||||
blockTypes = GlobalDataCache.blockTypes;
|
||||
showArea = GlobalDataCache.showArea;
|
||||
opacityVal = GlobalDataCache.opacityVal;
|
||||
fontSizeVal = GlobalDataCache.fontSizeVal;
|
||||
danmakuDurationVal = GlobalDataCache.danmakuDurationVal;
|
||||
strokeWidth = GlobalDataCache.strokeWidth;
|
||||
playRepeat = GlobalDataCache.playRepeat;
|
||||
_playbackSpeed.value = GlobalDataCache.playbackSpeed;
|
||||
enableAutoLongPressSpeed = GlobalDataCache.enableAutoLongPressSpeed;
|
||||
_longPressSpeed.value = GlobalDataCache.longPressSpeed;
|
||||
speedsList = GlobalDataCache.speedsList;
|
||||
// _playerEventSubs = onPlayerStatusChanged.listen((PlayerStatus status) {
|
||||
// if (status == PlayerStatus.playing) {
|
||||
// WakelockPlus.enable();
|
||||
@ -1047,13 +1046,12 @@ class PlPlayerController {
|
||||
|
||||
/// 缓存本次弹幕选项
|
||||
cacheDanmakuOption() {
|
||||
final cache = GlobalDataCache();
|
||||
cache.blockTypes = blockTypes;
|
||||
cache.showArea = showArea;
|
||||
cache.opacityVal = opacityVal;
|
||||
cache.fontSizeVal = fontSizeVal;
|
||||
cache.danmakuDurationVal = danmakuDurationVal;
|
||||
cache.strokeWidth = strokeWidth;
|
||||
GlobalDataCache.blockTypes = blockTypes;
|
||||
GlobalDataCache.showArea = showArea;
|
||||
GlobalDataCache.opacityVal = opacityVal;
|
||||
GlobalDataCache.fontSizeVal = fontSizeVal;
|
||||
GlobalDataCache.danmakuDurationVal = danmakuDurationVal;
|
||||
GlobalDataCache.strokeWidth = strokeWidth;
|
||||
|
||||
localCache.put(LocalCacheKey.danmakuBlockType, blockTypes);
|
||||
localCache.put(LocalCacheKey.danmakuShowArea, showArea);
|
||||
|
||||
@ -89,7 +89,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
late bool enableBackgroundPlay;
|
||||
late double screenWidth;
|
||||
final FullScreenGestureMode fullScreenGestureMode =
|
||||
GlobalDataCache().fullScreenGestureMode;
|
||||
GlobalDataCache.fullScreenGestureMode;
|
||||
|
||||
// 用于记录上一次全屏切换手势触发时间,避免误触
|
||||
DateTime? lastFullScreenToggleTime;
|
||||
@ -136,7 +136,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
screenWidth = Get.size.width;
|
||||
animationController = AnimationController(
|
||||
vsync: this,
|
||||
duration: GlobalDataCache().enablePlayerControlAnimation
|
||||
duration: GlobalDataCache.enablePlayerControlAnimation
|
||||
? const Duration(milliseconds: 150)
|
||||
: const Duration(milliseconds: 10),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user