28 lines
1 KiB
Dart
28 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;
|
||
|
|
}
|