fix: 弹幕显示&弹幕设置缓存

This commit is contained in:
guozhigq
2024-06-11 22:59:07 +08:00
parent 128c9201bd
commit 7af1ebd3d5
3 changed files with 37 additions and 25 deletions

View File

@ -591,27 +591,32 @@ class _VideoDetailPageState extends State<VideoDetailPage>
verticalScreen(); verticalScreen();
} }
}, },
child: Hero( child: LayoutBuilder(
tag: heroTag, builder: (BuildContext context,
child: Stack( BoxConstraints constraints) {
children: <Widget>[ return Hero(
if (isShowing) videoPlayerPanel, tag: heroTag,
child: Stack(
children: <Widget>[
if (isShowing) videoPlayerPanel,
/// 关闭自动播放时 手动播放 /// 关闭自动播放时 手动播放
Obx( Obx(
() => Visibility( () => Visibility(
visible: !vdCtr.autoPlay.value && visible: !vdCtr.autoPlay.value &&
vdCtr.isShowCover.value, vdCtr.isShowCover.value,
child: Positioned( child: Positioned(
top: 0, top: 0,
left: 0, left: 0,
right: 0, right: 0,
child: handlePlayPanel(), child: handlePlayPanel(),
),
),
), ),
), ],
), ),
], );
), },
), ),
), ),
), ),

View File

@ -1069,7 +1069,9 @@ class _HeaderControlState extends State<HeaderControl> {
); );
}); });
}, },
); ).then((value) {
widget.controller!.cacheDanmakuOption();
});
} }
/// 播放顺序 /// 播放顺序

View File

@ -1089,6 +1089,16 @@ class PlPlayerController {
videoStorage.put(VideoBoxKey.playRepeat, type.value); videoStorage.put(VideoBoxKey.playRepeat, type.value);
} }
/// 缓存本次弹幕选项
cacheDanmakuOption() {
localCache.put(LocalCacheKey.danmakuBlockType, blockTypes);
localCache.put(LocalCacheKey.danmakuShowArea, showArea);
localCache.put(LocalCacheKey.danmakuOpacity, opacityVal);
localCache.put(LocalCacheKey.danmakuFontScale, fontSizeVal);
localCache.put(LocalCacheKey.danmakuDuration, danmakuDurationVal);
localCache.put(LocalCacheKey.strokeWidth, strokeWidth);
}
Future<void> dispose({String type = 'single'}) async { Future<void> dispose({String type = 'single'}) async {
// 每次减1最后销毁 // 每次减1最后销毁
if (type == 'single' && playerCount.value > 1) { if (type == 'single' && playerCount.value > 1) {
@ -1118,12 +1128,7 @@ class PlPlayerController {
// dataStatus.status.close(); // dataStatus.status.close();
/// 缓存本次弹幕选项 /// 缓存本次弹幕选项
localCache.put(LocalCacheKey.danmakuBlockType, blockTypes); cacheDanmakuOption();
localCache.put(LocalCacheKey.danmakuShowArea, showArea);
localCache.put(LocalCacheKey.danmakuOpacity, opacityVal);
localCache.put(LocalCacheKey.danmakuFontScale, fontSizeVal);
localCache.put(LocalCacheKey.danmakuDuration, danmakuDurationVal);
localCache.put(LocalCacheKey.strokeWidth, strokeWidth);
if (_videoPlayerController != null) { if (_videoPlayerController != null) {
var pp = _videoPlayerController!.platform as NativePlayer; var pp = _videoPlayerController!.platform as NativePlayer;
await pp.setProperty('audio-files', ''); await pp.setProperty('audio-files', '');