fix: 单个循环失效、继续播放时控件跳跃、冗余参数移除、typo修正

This commit is contained in:
orz12
2024-06-13 20:32:14 +08:00
parent 6ac24ef52c
commit a9f7d2f3a6
2 changed files with 13 additions and 19 deletions

View File

@@ -289,9 +289,9 @@ class PlPlayerController {
}
static Future<void> playIfExists(
{bool repeat = false, bool hideControls = true, dynamic duration}) async {
{bool repeat = false, bool hideControls = true}) async {
await _instance?.play(
repeat: repeat, hideControls: hideControls, duration: duration);
repeat: repeat, hideControls: hideControls);
}
// try to get PlayerStatus
@@ -610,8 +610,7 @@ class PlPlayerController {
// 开始播放
Future _initializePlayer({
Duration seekTo = Duration.zero,
Duration? duration,
Duration seekTo = Duration.zero
}) async {
if (_instance == null) return;
// 设置倍速
@@ -636,7 +635,7 @@ class PlPlayerController {
// 自动播放
if (_autoPlay) {
await playIfExists(duration: duration);
await playIfExists();
// await play(duration: duration);
}
}
@@ -831,20 +830,16 @@ class PlPlayerController {
/// 播放视频
/// TODO _duration.value丢失
Future<void> play(
{bool repeat = false, bool hideControls = true, dynamic duration}) async {
{bool repeat = false, bool hideControls = true}) async {
if (_playerCount.value == 0) return;
// 播放时自动隐藏控制条
controls = !hideControls;
// repeat为true将从头播放
if (repeat) {
await seekTo(Duration.zero);
// await seekTo(Duration.zero);
await seekTo(Duration.zero, type: "slider");
}
/// 临时fix _duration.value丢失
if (duration != null) {
_duration.value = duration;
updateDurationSecond();
}
await _videoPlayerController?.play();
await getCurrentVolume();