Fix YouTube relay instabile e timer LIVE a zero in app
ffmpeg: probesize/analyzeduration su _air, restart più rapido e avvio relay al go_live. App: sincronizza started_at dal server e fallback al passaggio live. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -41,6 +41,7 @@ class _CameraScreenState extends ConsumerState<CameraScreen> {
|
||||
static const _previewKey = ValueKey<String>('camera_streaming_preview');
|
||||
|
||||
Timer? _elapsedTimer;
|
||||
Timer? _sessionSyncTimer;
|
||||
Timer? _telemetryTimer;
|
||||
Timer? _statsTimer;
|
||||
Timer? _scorePullTimer;
|
||||
@@ -75,6 +76,9 @@ class _CameraScreenState extends ConsumerState<CameraScreen> {
|
||||
);
|
||||
}
|
||||
});
|
||||
_sessionSyncTimer = Timer.periodic(const Duration(seconds: 15), (_) {
|
||||
unawaited(_syncSessionStartedAt());
|
||||
});
|
||||
_telemetryTimer = Timer.periodic(const Duration(seconds: 10), (_) => _sendTelemetry());
|
||||
_statsTimer = Timer.periodic(const Duration(seconds: 30), (_) => _fetchStats());
|
||||
_scorePullTimer = Timer.periodic(const Duration(seconds: 2), (_) {
|
||||
@@ -263,6 +267,20 @@ class _CameraScreenState extends ConsumerState<CameraScreen> {
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
/// Il server imposta `started_at` solo al primo go_live; sincronizza per il timer LIVE.
|
||||
Future<void> _syncSessionStartedAt() async {
|
||||
final current = ref.read(sessionProvider).session;
|
||||
if (current == null || current.startedAt != null || !current.isLive) return;
|
||||
try {
|
||||
final fresh = await ref.read(apiClientProvider).fetchSession(widget.sessionId);
|
||||
if (!mounted || fresh.startedAt == null) return;
|
||||
ref.read(sessionProvider.notifier).setSession(
|
||||
fresh,
|
||||
match: ref.read(sessionProvider).match,
|
||||
);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<void> _lockOrientations() async {
|
||||
await SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.landscapeLeft,
|
||||
@@ -497,6 +515,7 @@ class _CameraScreenState extends ConsumerState<CameraScreen> {
|
||||
@override
|
||||
void dispose() {
|
||||
_elapsedTimer?.cancel();
|
||||
_sessionSyncTimer?.cancel();
|
||||
_telemetryTimer?.cancel();
|
||||
_statsTimer?.cancel();
|
||||
_scorePullTimer?.cancel();
|
||||
|
||||
Reference in New Issue
Block a user