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>
27 lines
1 KiB
Dart
27 lines
1 KiB
Dart
import 'package:frosty/screens/channel/video/video_timing_constants.dart';
|
|
|
|
/// Whether [NativeVideoStore] should auto-refresh after a mid-stream player
|
|
/// error instead of pinning the Reload overlay.
|
|
///
|
|
/// ExoPlayer's "Source error" (screen-off / network switch) arrives without a
|
|
/// status code, so callers must not rely on 4xx alone. [mediaServicesWereReset]
|
|
/// has its own dispose+rebuild path and is excluded here.
|
|
bool shouldAutoRecoverFromPlayerError({
|
|
required bool refreshCapReached,
|
|
String? errorCode,
|
|
}) {
|
|
if (refreshCapReached) return false;
|
|
if (errorCode == 'mediaServicesWereReset') return false;
|
|
return true;
|
|
}
|
|
|
|
/// Delay before an automatic refresh for [statusCode].
|
|
///
|
|
/// Token/CDN 4xx can refresh immediately; network/source failures get a short
|
|
/// pause so the interface can come back after a switch or screen wake.
|
|
Duration playerErrorRetryDelay({int? statusCode}) {
|
|
if (statusCode != null && statusCode >= 400 && statusCode < 500) {
|
|
return Duration.zero;
|
|
}
|
|
return VideoTimingConstants.initRetryDelay;
|
|
}
|