fix(player): 预解码观看全集首帧

This commit is contained in:
Zhou Weidong committed 2026-10-26 17:27:43 +08:00
1 parent 1fc8c4924e
commit c8ec481fc9
5 files changed
+145 -26

No files matched your search

+16 -6
View File
@@ -230,7 +230,6 @@ class PlayerLogic extends ChangeNotifier {
cancelScrub();
await session.pauseForRouteHandoff();
_logFeedHandoff('paused');
await saveCurrentProgress();
}
/// 独立播放页关闭并恢复首页路由后,等原生播放器实际恢复再结束交接。
@@ -1230,27 +1229,38 @@ class PlayerLogic extends ChangeNotifier {
Drama drama,
int index,
) async {
final initialFrameBytes = await PlayerFrameCapture.capture(
final fallbackPosterUrl = index >= 0 && index < drama.episodes.length
? drama.episodes[index].posterUrl
: null;
final preparedFrame = await PlayerFrameCapture.captureAndPrecache(
context: context,
boundaryKey: renderBoundaryKey,
source: 'watch-all',
fallbackPosterUrl: fallbackPosterUrl,
);
if (!context.mounted) return;
await pauseForFullPlayer();
if (!context.mounted) return;
await Navigator.of(context).push(
final route = Navigator.of(context).push(
FadePageRoute<void>(
transitionDuration: const Duration(milliseconds: 180),
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero,
builder: (_) => PlayerPage(
drama: drama,
initialIndex: index,
wallet: wallet,
downloads: downloads,
revealAfterFirstFrame: initialFrameBytes != null,
initialFrameBytes: initialFrameBytes,
revealAfterFirstFrame: preparedFrame.isReady,
initialFrameBytes: preparedFrame.bytes,
initialFrameProvider: preparedFrame.provider,
),
),
);
if (kDebugMode) {
debugPrint('[player-entry] phase=route-pushed source=watch-all ms=0');
}
unawaited(saveCurrentProgress());
await route;
if (!isMounted()) return;
await resumeAfterFullPlayer();
}