Auto-recover native player after Source errors.
Screen-off and network switches often leave ExoPlayer dead without a 4xx status; refresh automatically (and on app resume) instead of waiting for Reload. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
59290b23b1
commit
eb39a4ac00
3 changed files with 129 additions and 14 deletions
56
test/screens/channel/video/playback_error_recovery_test.dart
Normal file
56
test/screens/channel/video/playback_error_recovery_test.dart
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:frosty/screens/channel/video/playback_error_recovery.dart';
|
||||
import 'package:frosty/screens/channel/video/video_timing_constants.dart';
|
||||
|
||||
void main() {
|
||||
group('shouldAutoRecoverFromPlayerError', () {
|
||||
test('recovers Source error / generic failures under the refresh cap', () {
|
||||
expect(
|
||||
shouldAutoRecoverFromPlayerError(refreshCapReached: false),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
shouldAutoRecoverFromPlayerError(
|
||||
refreshCapReached: false,
|
||||
errorCode: null,
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
test('stops once the refresh cap is reached', () {
|
||||
expect(
|
||||
shouldAutoRecoverFromPlayerError(refreshCapReached: true),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('defers mediaServicesWereReset to its dedicated rebuild path', () {
|
||||
expect(
|
||||
shouldAutoRecoverFromPlayerError(
|
||||
refreshCapReached: false,
|
||||
errorCode: 'mediaServicesWereReset',
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('playerErrorRetryDelay', () {
|
||||
test('refreshes 4xx token failures immediately', () {
|
||||
expect(playerErrorRetryDelay(statusCode: 403), Duration.zero);
|
||||
expect(playerErrorRetryDelay(statusCode: 404), Duration.zero);
|
||||
});
|
||||
|
||||
test('waits briefly for network / Source errors without status', () {
|
||||
expect(
|
||||
playerErrorRetryDelay(),
|
||||
VideoTimingConstants.initRetryDelay,
|
||||
);
|
||||
expect(
|
||||
playerErrorRetryDelay(statusCode: 500),
|
||||
VideoTimingConstants.initRetryDelay,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue