fix: 视频跳转画面停留、视频继续进度播放
This commit is contained in:
@ -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();
|
||||
|
@ -648,6 +648,23 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
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)
|
||||
|
Reference in New Issue
Block a user