fix(player): 修复返回首页黑屏并恢复预热

This commit is contained in:
Zhou Weidong committed 2026-10-26 16:45:00 +08:00
1 parent 6667330ce0
commit 54eb5a60a8
9 files changed
+56 -101

No files matched your search

@@ -69,7 +69,6 @@ Future<void> _placeNeighbor(PlaybackSession session, _PlayerSlot? slot) async {
/// 当前集已经出画后,按手势方向静默准备上一集和下一集。
void _warmNeighbors(PlaybackSession session, {bool preferredNext = true}) {
if (!session.warmNeighborsEnabled) return;
final request = session._generation;
final nextTask = _warmOne(session, request, session._nextIndex, next: true);
final previousTask = _warmOne(
+2 -4
View File
@@ -27,7 +27,6 @@ class PlaybackSession extends ChangeNotifier {
this.activate,
PlaybackCoordinator? coordinator,
this.waitForFrame,
this.warmNeighborsEnabled = true,
}) : _coordinator = coordinator ?? PlaybackCoordinator();
final List<Episode> episodes;
@@ -40,7 +39,6 @@ class PlaybackSession extends ChangeNotifier {
/// Runs only when a slot becomes current (e.g. progress listeners).
final PlayerPreparation? activate;
final Future<void> Function()? waitForFrame;
final bool warmNeighborsEnabled;
final PlaybackCoordinator _coordinator;
final Set<_PlayerSlot> _live = {};
_PlayerSlot? _active;
@@ -142,8 +140,8 @@ class PlaybackSession extends ChangeNotifier {
}
void _rememberNeighbors(int? preloadIndex, int? previousIndex) {
_nextIndex = warmNeighborsEnabled ? preloadIndex : null;
_previousIndex = warmNeighborsEnabled ? previousIndex : null;
_nextIndex = preloadIndex;
_previousIndex = previousIndex;
}
Future<void> _enqueue(Future<void> Function() operation) {
@@ -6,12 +6,7 @@ part of 'playback_session.dart';
extension PlaybackSessionControls on PlaybackSession {
/// 滑动手势开始时按方向优先准备相邻集,不改变当前集播放状态。
void prewarmNeighbors({required bool forward}) {
if (!warmNeighborsEnabled ||
!_visible ||
_overlayOpen ||
_active?.prepared != true) {
return;
}
if (!_visible || _overlayOpen || _active?.prepared != true) return;
_warmNeighbors(this, preferredNext: forward);
}
@@ -62,6 +57,7 @@ extension PlaybackSessionControls on PlaybackSession {
slot.activated = true;
}
await _applyPlayback(slot);
if (_visible && !_overlayOpen && !_loading) _warmNeighbors(this);
if (kDebugMode) {
debugPrint(
'[feed-handoff] phase=resumed activated=${slot.activated} '
@@ -2,6 +2,7 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:video_player/video_player.dart';
import '../../config/app_config.dart';
@@ -68,6 +69,13 @@ class VideoPlayerPort implements PlayerPort {
Future<void> dispose() async {
if (_disposed) return;
_disposed = true;
if (kDebugMode) {
debugPrint(
'[player-controller] phase=dispose '
'controller=${identityHashCode(controller)} '
'source=${controller.dataSource}\n${StackTrace.current}',
);
}
try {
await _initialization;
} catch (_) {