From 17b02d9ae93f105d137dfa649be9cbc322154dd3 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 12 Aug 2023 22:19:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=86=E9=A2=91=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E5=81=9C=E7=95=99=E3=80=81=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E8=BF=9B=E5=BA=A6=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugin/pl_player/controller.dart | 9 ++++----- lib/plugin/pl_player/view.dart | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 934e34b4..e801ab36 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -230,8 +230,6 @@ class PlPlayerController { try { _autoPlay = autoplay; _looping = looping; - // 初始化视频时长 - _duration.value = duration ?? Duration.zero; // 初始化视频倍速 _playbackSpeed.value = speed; // 初始化数据加载状态 @@ -248,7 +246,7 @@ class PlPlayerController { _videoPlayerController = await _createVideoController( dataSource, _looping, enableHA, width, height); // 获取视频时长 00:00 - _duration.value = _videoPlayerController!.state.duration; + _duration.value = duration ?? _videoPlayerController!.state.duration; // 数据加载完成 dataStatus.status.value = DataStatus.loaded; @@ -274,7 +272,8 @@ class PlPlayerController { ) async { // 每次配置时先移除监听 removeListeners(); - + isBuffering.value = false; + buffered.value = Duration.zero; Player player = _videoPlayerController ?? Player( configuration: const PlayerConfiguration( @@ -430,7 +429,7 @@ class PlPlayerController { } _position.value = position; if (duration.value.inSeconds != 0) { - // await _videoPlayerController!.stream.buffer.first; + await _videoPlayerController!.stream.buffer.first; await _videoPlayerController?.seek(position); // if (playerStatus.stopped) { // play(); diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index aa3349e9..6df96967 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -648,6 +648,23 @@ class _PLVideoPlayerState extends State return Container(); } }), + Obx(() { + if (_.buffered.value == Duration.zero) { + return Positioned.fill( + child: Container( + color: Colors.black, + child: Center( + child: Image.asset( + 'assets/images/loading.gif', + height: 25, + ), + ), + ), + ); + } else { + return Container(); + } + }), /// 点击 快进/快退 if (_mountSeekBackwardButton || _mountSeekForwardButton)