fix: 关闭自动播放时播放器初始化逻辑、播放器插件回滚(高版本页面回退时不会自动继续播放)

This commit is contained in:
guozhigq
2023-08-27 22:00:46 +08:00
parent 4e2808fab7
commit ce1daec3c5
4 changed files with 71 additions and 54 deletions

View File

@ -41,7 +41,6 @@ class VideoDetailController extends GetxController
late VideoQuality currentVideoQa;
AudioQuality? currentAudioQa;
late VideoDecodeFormats currentDecodeFormats;
// PlPlayerController plPlayerController = PlPlayerController();
// 是否开始自动播放 存在多p的情况下第二p需要为true
RxBool autoPlay = true.obs;
// 视频资源是否有效
@ -183,7 +182,6 @@ class VideoDetailController extends GetxController
),
// 硬解
enableHA: enableHA.value,
autoplay: autoPlay.value,
seekTo: seekToTime ?? defaultST,
duration: duration ?? Duration(milliseconds: data.timeLength ?? 0),
// 宽>高 水平 否则 垂直
@ -198,11 +196,6 @@ class VideoDetailController extends GetxController
);
}
// 手动点击播放
handlePlay() {
plPlayerController.togglePlay();
}
// 视频链接
Future queryVideoUrl() async {
var result = await VideoHttp.videoUrl(cid: cid, bvid: bvid);
@ -292,7 +285,9 @@ class VideoDetailController extends GetxController
currentAudioQa = AudioQualityCode.fromCode(firstAudio.id!)!;
}
defaultST = Duration(milliseconds: data.lastPlayTime!);
await playerInit();
if (autoPlay.value) {
await playerInit();
}
} else {
if (result['code'] == -404) {
isShowCover.value = false;