opt: init play

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-06 14:23:02 +08:00
parent d0046d0faf
commit 3d803cce9f
3 changed files with 16 additions and 13 deletions

View File

@@ -1090,6 +1090,11 @@ class VideoDetailController extends GetxController
epid: videoType == SearchType.media_bangumi ? epId : null, epid: videoType == SearchType.media_bangumi ? epId : null,
seasonId: videoType == SearchType.media_bangumi ? seasonId : null, seasonId: videoType == SearchType.media_bangumi ? seasonId : null,
subType: videoType == SearchType.media_bangumi ? subType : null, subType: videoType == SearchType.media_bangumi ? subType : null,
callback: () {
if (videoState.value is! Success) {
videoState.value = LoadingState.success(null);
}
},
); );
_initSkip(); _initSkip();
@@ -1162,7 +1167,6 @@ class VideoDetailController extends GetxController
if (autoPlay.value) { if (autoPlay.value) {
isShowCover.value = false; isShowCover.value = false;
await playerInit(); await playerInit();
videoState.value = LoadingState.success(null);
} }
isQuerying = false; isQuerying = false;
return; return;
@@ -1271,7 +1275,6 @@ class VideoDetailController extends GetxController
if (autoPlay.value) { if (autoPlay.value) {
isShowCover.value = false; isShowCover.value = false;
await playerInit(); await playerInit();
videoState.value = LoadingState.success(null);
} }
} else { } else {
autoPlay.value = false; autoPlay.value = false;

View File

@@ -293,9 +293,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
} }
plPlayerController = videoDetailController.plPlayerController; plPlayerController = videoDetailController.plPlayerController;
videoDetailController.isShowCover.value = false; videoDetailController.isShowCover.value = false;
await videoDetailController.playerInit(autoplay: true);
videoDetailController.autoPlay.value = true; videoDetailController.autoPlay.value = true;
videoDetailController.videoState.value = LoadingState.success(null); await videoDetailController.playerInit(autoplay: true);
plPlayerController!.addStatusLister(playerListener); plPlayerController!.addStatusLister(playerListener);
plPlayerController!.addPositionListener(positionListener); plPlayerController!.addPositionListener(positionListener);
await plPlayerController!.autoEnterFullscreen(); await plPlayerController!.autoEnterFullscreen();

View File

@@ -464,6 +464,7 @@ class PlPlayerController {
dynamic epid, dynamic epid,
dynamic seasonId, dynamic seasonId,
dynamic subType, dynamic subType,
VoidCallback? callback,
}) async { }) async {
try { try {
this.dataSource = dataSource; this.dataSource = dataSource;
@@ -498,6 +499,7 @@ class PlPlayerController {
// 配置Player 音轨、字幕等等 // 配置Player 音轨、字幕等等
_videoPlayerController = await _createVideoController( _videoPlayerController = await _createVideoController(
dataSource, _looping, enableHA, hwdec, width, height); dataSource, _looping, enableHA, hwdec, width, height);
callback?.call();
// 获取视频时长 00:00 // 获取视频时长 00:00
_duration.value = duration ?? _videoPlayerController!.state.duration; _duration.value = duration ?? _videoPlayerController!.state.duration;
_position.value = _position.value =
@@ -601,8 +603,7 @@ class PlPlayerController {
await pp.setProperty("blend-subtitles", "video"); await pp.setProperty("blend-subtitles", "video");
} }
_videoController = _videoController ?? _videoController ??= VideoController(
VideoController(
player, player,
configuration: VideoControllerConfiguration( configuration: VideoControllerConfiguration(
enableHardwareAcceleration: enableHA, enableHardwareAcceleration: enableHA,