fix(player): 收紧图片与快速切集资源占用
This commit is contained in:
1 parent
2fef7470e0
commit
80c962a95c
10 files changed
+281
-30
No files matched your search
@@ -353,6 +353,28 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _selectPage(int index) async {
|
||||
await logic.requestEpisodeSelection(index);
|
||||
if (!mounted || logic.session.currentIndex != index) return;
|
||||
await logic.session.preloadSettled;
|
||||
if (!mounted || logic.session.currentIndex != index) return;
|
||||
_logResourceWatermark();
|
||||
}
|
||||
|
||||
void _logResourceWatermark() {
|
||||
if (!kDebugMode) return;
|
||||
final imageCache = PaintingBinding.instance.imageCache;
|
||||
debugPrint(
|
||||
'[player-resources] '
|
||||
'slots=${logic.session.livePlayerCount} '
|
||||
'warmNext=${logic.session.preloadedIndex ?? '-'} '
|
||||
'warmPrevious=${logic.session.previousPreloadedIndex ?? '-'} '
|
||||
'sprites=${_spriteAxisService.spriteCacheSize} '
|
||||
'imageCacheBytes=${imageCache.currentSizeBytes} '
|
||||
'imageCacheCount=${imageCache.currentSize}',
|
||||
);
|
||||
}
|
||||
|
||||
void _setScrubbing(bool value) {
|
||||
if (!mounted) return;
|
||||
if (_scrubbing == value) return;
|
||||
@@ -507,7 +529,7 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
onPageChanged: (position) {
|
||||
final index = indices[position];
|
||||
widget.onDramaChanged?.call(logic.queue.entryAt(index).drama);
|
||||
unawaited(logic.selectEpisode(index));
|
||||
unawaited(_selectPage(index));
|
||||
if (position >= indices.length - 3) {
|
||||
final loadMore = widget.onLoadMore;
|
||||
if (loadMore != null) unawaited(loadMore());
|
||||
|
||||
Reference in new issue
Block a user