fix(player): 收紧图片与快速切集资源占用
This commit is contained in:
1 parent
2fef7470e0
commit
80c962a95c
10 files changed
+281
-30
No files matched your search
@@ -93,6 +93,9 @@ class PlayerLogic extends ChangeNotifier {
|
||||
String selectedQuality = 'AUTO';
|
||||
Duration? _qualitySeek;
|
||||
int pageRequest = 0;
|
||||
int? _pendingSelectionIndex;
|
||||
int? _pendingSelectionRevision;
|
||||
Future<void>? _selectionDrain;
|
||||
bool muted = false;
|
||||
double playbackSpeed = 1.0;
|
||||
bool stoppedAtFeedEnd = false;
|
||||
@@ -957,6 +960,37 @@ class PlayerLogic extends ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
/// 翻页入口使用 single-flight:执行中的切集不被重复排队,只保留最新目标。
|
||||
Future<void> requestEpisodeSelection(int index, {int? revision}) {
|
||||
if (_disposed || index < 0 || index >= sessionEpisodes.length) {
|
||||
return Future<void>.value();
|
||||
}
|
||||
_pendingSelectionIndex = index;
|
||||
_pendingSelectionRevision = revision;
|
||||
return _selectionDrain ??= _drainEpisodeSelections();
|
||||
}
|
||||
|
||||
Future<void> _drainEpisodeSelections() async {
|
||||
try {
|
||||
while (!_disposed) {
|
||||
final index = _pendingSelectionIndex;
|
||||
if (index == null) break;
|
||||
final revision = _pendingSelectionRevision;
|
||||
_pendingSelectionIndex = null;
|
||||
_pendingSelectionRevision = null;
|
||||
await selectEpisode(index, revision: revision);
|
||||
}
|
||||
} finally {
|
||||
_selectionDrain = null;
|
||||
final index = _pendingSelectionIndex;
|
||||
if (!_disposed && index != null) {
|
||||
unawaited(
|
||||
requestEpisodeSelection(index, revision: _pendingSelectionRevision),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> selectEpisode(int index, {int? revision}) async {
|
||||
final feedRevisionAtStart = revision ?? feedRevision;
|
||||
final request = ++pageRequest;
|
||||
|
||||
Reference in new issue
Block a user