YouTube come destinazione pubblica, non Match Live TV.
Non propone più il link MLTV per sessioni YouTube; la pagina /live reindirizza a YouTube; il relay verso YouTube si riavvia al connect. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -45,6 +45,7 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
|
||||
int _latencyMs = 0;
|
||||
String _networkType = '—';
|
||||
bool _starting = false;
|
||||
Timer? _youtubePoll;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -54,6 +55,45 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
|
||||
if (session?.score != null) {
|
||||
ref.read(scoreProvider.notifier).reset(session!.score!);
|
||||
}
|
||||
_startYoutubeLinkPoll();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_youtubePoll?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _startYoutubeLinkPoll() {
|
||||
final session = ref.read(sessionProvider).session;
|
||||
if (session == null || session.platform != 'youtube') return;
|
||||
if (session.youtubeReady || (session.youtubeWatchUrl?.isNotEmpty ?? false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_youtubePoll?.cancel();
|
||||
var attempts = 0;
|
||||
_youtubePoll = Timer.periodic(const Duration(seconds: 2), (_) async {
|
||||
attempts++;
|
||||
if (!mounted || attempts > 30) {
|
||||
_youtubePoll?.cancel();
|
||||
return;
|
||||
}
|
||||
final current = ref.read(sessionProvider).session;
|
||||
if (current == null) return;
|
||||
try {
|
||||
final updated =
|
||||
await ref.read(apiClientProvider).fetchSession(current.id);
|
||||
ref
|
||||
.read(sessionProvider.notifier)
|
||||
.setSession(updated, match: ref.read(sessionProvider).match);
|
||||
if (updated.youtubeReady ||
|
||||
(updated.youtubeWatchUrl?.isNotEmpty ?? false)) {
|
||||
_youtubePoll?.cancel();
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
} catch (_) {}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -240,6 +280,24 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
if (_testCompleted &&
|
||||
session != null &&
|
||||
session.platform == 'youtube' &&
|
||||
shareUrl == null) ...[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.surfaceElevated,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Text(
|
||||
'Preparazione diretta sul canale YouTube Match Live TV… '
|
||||
'Il link apparirà qui tra pochi secondi.',
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
if (_testCompleted && session != null && shareUrl != null) ...[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
@@ -252,7 +310,7 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
|
||||
children: [
|
||||
Text(
|
||||
session.platform == 'youtube'
|
||||
? 'Link video YouTube'
|
||||
? 'Link diretta YouTube (canale Match Live TV)'
|
||||
: 'Link diretta Match Live TV',
|
||||
style: theme.textTheme.titleSmall,
|
||||
),
|
||||
@@ -261,6 +319,13 @@ class _StepNetworkTestState extends ConsumerState<StepNetworkTest> {
|
||||
shareUrl,
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
if (session.platform == 'youtube') ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'Condividi solo questo link: gli spettatori guardano su YouTube, non sul sito.',
|
||||
style: theme.textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user