fix(player): 修复竖滑上一集不自动播放

This commit is contained in:
Zhou Weidong committed 2026-10-26 13:43:43 +08:00
1 parent df36890b48
commit 516593499c
10 files changed
+264 -80

No files matched your search

+58
View File
@@ -148,6 +148,64 @@ void main() {
await session.close();
});
test('should_play_previous_episode_when_swiping_back', () async {
final factory = _Factory();
final session = PlaybackSession(
episodes: episodes,
factory: factory.create,
canPlay: (_) => true,
);
await session.select(1, preloadIndex: 2, previousIndex: 0);
await session.preloadSettled;
await session.select(2, preloadIndex: 3, previousIndex: 1);
await session.preloadSettled;
expect(session.active, isA<_Player>().having((p) => p.id, 'id', 'ep-2'));
await session.select(1, preloadIndex: 2, previousIndex: 0);
await session.preloadSettled;
expect(session.active, isA<_Player>().having((p) => p.id, 'id', 'ep-1'));
expect(
factory.players.firstWhere((player) => player.id == 'ep-1').playing,
isTrue,
);
expect(session.userWantsPlay, isTrue);
await session.close();
});
test('should_keep_manual_pause_when_returning_to_same_episode', () async {
final factory = _Factory();
final session = PlaybackSession(
episodes: episodes,
factory: factory.create,
canPlay: (_) => true,
);
await session.select(1, preloadIndex: 2, previousIndex: 0);
await session.preloadSettled;
session.setUserWantsPlay(false);
await session.playbackSettled;
expect(session.userWantsPlay, isFalse);
await session.select(2, preloadIndex: 3, previousIndex: 1);
await session.preloadSettled;
expect(session.userWantsPlay, isTrue);
expect(
factory.players.firstWhere((player) => player.id == 'ep-2').playing,
isTrue,
);
await session.select(1, preloadIndex: 2, previousIndex: 0);
await session.preloadSettled;
expect(session.userWantsPlay, isFalse);
expect(
factory.players.firstWhere((player) => player.id == 'ep-1').playing,
isFalse,
);
await session.close();
});
test('should_reuse_in_flight_preload_when_swiped_before_ready', () async {
final gate = Completer<void>();
final factory = _Factory(gates: {'ep-1': gate});
+1 -1
View File
@@ -30,7 +30,7 @@ void main() {
scrubPreviewLeft(trackWidth: 300, fraction: 1),
300 - scrubPreviewWidth - scrubPreviewSafeMargin,
);
expect(scrubPreviewLeft(trackWidth: 100, fraction: 0.5), 0);
expect(scrubPreviewLeft(trackWidth: 100, fraction: 0.5), 2);
});
testWidgets('should_show_inactive_track_when_video_is_not_initialized', (