fix: player key

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-27 16:52:33 +08:00
parent 609fab345a
commit 587870ad71
3 changed files with 24 additions and 21 deletions

View File

@@ -289,8 +289,6 @@ class PlPlayerController {
// 播放顺序相关
PlayRepeat playRepeat = PlayRepeat.pause;
GlobalKey<VideoState> key = GlobalKey<VideoState>();
TextStyle get subTitleStyle => TextStyle(
height: 1.5,
fontSize:
@@ -313,10 +311,12 @@ class PlPlayerController {
textScaleFactor: MediaQuery.textScalerOf(Get.context!).scale(1),
);
late Function getPlayerKey;
void updateSubtitleStyle() {
key.currentState?.update(
subtitleViewConfiguration: subtitleViewConfiguration,
);
getPlayerKey().currentState?.update(
subtitleViewConfiguration: subtitleViewConfiguration,
);
}
void updateSliderPositionSecond() {

View File

@@ -84,6 +84,7 @@ 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;
@@ -160,7 +161,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
@override
void initState() {
super.initState();
plPlayerController.key = GlobalKey<VideoState>();
animationController = AnimationController(
vsync: this, duration: const Duration(milliseconds: 100));
videoController = plPlayerController.videoController!;
@@ -169,6 +169,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
plPlayerController.headerControl = widget.headerControl;
plPlayerController.bottomControl = widget.bottomControl;
plPlayerController.danmuWidget = widget.danmuWidget;
plPlayerController.getPlayerKey = () => key;
defaultBtmProgressBehavior = GStorage.setting.get(
SettingBoxKey.btmProgressBehavior,
defaultValue: BtmProgressBehavior.values.first.code);
@@ -898,7 +899,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
flipY: plPlayerController.flipY.value,
child: Video(
fill: widget.fill ?? Colors.black,
key: plPlayerController.key,
key: key,
controller: videoController,
controls: NoVideoControls,
pauseUponEnteringBackgroundMode: