From 98c2a4243df38d49ac96ce8fdd8e954756c9cd73 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 13 Nov 2023 23:53:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20duration=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E5=BC=B9=E5=B9=95=E5=8A=A0=E8=BD=BD=E9=97=AE=E9=A2=98=20issues?= =?UTF-8?q?=20#241?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugin/pl_player/controller.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 17f461ac..8f09d0ca 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -338,7 +338,7 @@ class PlPlayerController { if (!_listenersInitialized) { startListeners(); } - await _initializePlayer(seekTo: seekTo); + await _initializePlayer(seekTo: seekTo, duration: _duration.value); bool autoEnterFullcreen = setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false); if (autoEnterFullcreen && _isFirstTime) { @@ -444,6 +444,7 @@ class PlPlayerController { // 开始播放 Future _initializePlayer({ Duration seekTo = Duration.zero, + Duration? duration, }) async { // 设置倍速 if (videoType.value == 'live') { @@ -467,7 +468,7 @@ class PlPlayerController { // 自动播放 if (_autoPlay) { - await play(); + await play(duration: duration); } } @@ -596,6 +597,7 @@ class PlPlayerController { /// 设置倍速 Future setPlaybackSpeed(double speed) async { + /// TODO _duration.value丢失 await _videoPlayerController?.setRate(speed); try { DanmakuOption currentOption = danmakuController!.option; @@ -631,7 +633,9 @@ class PlPlayerController { // } /// 播放视频 - Future play({bool repeat = false, bool hideControls = true}) async { + /// TODO _duration.value丢失 + Future play( + {bool repeat = false, bool hideControls = true, dynamic duration}) async { // 播放时自动隐藏控制条 controls = !hideControls; // repeat为true,将从头播放 @@ -645,6 +649,9 @@ class PlPlayerController { playerStatus.status.value = PlayerStatus.playing; // screenManager.setOverlays(false); + + /// 临时fix _duration.value丢失 + _duration.value = duration; audioSessionHandler.setActive(true); }