From 40e72fcd8063402c03109b5b1f4ac7f907c26328 Mon Sep 17 00:00:00 2001 From: Bonfra04 Date: Tue, 6 Aug 2024 00:18:43 +0200 Subject: [PATCH] error message if something goes wrong during player querying --- lib/pages/player_page.dart | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/pages/player_page.dart b/lib/pages/player_page.dart index 1f33e0c..8317822 100644 --- a/lib/pages/player_page.dart +++ b/lib/pages/player_page.dart @@ -72,6 +72,11 @@ class _PlayerPageState extends State { () => playerInfo.watchable.player.getSource(playerInfo.watchable) ), builder: (context, snapshot) { + if (snapshot.hasError) { + Future.microtask(() => this._errorPlaying()); + return const Center(child: CircularProgressIndicator()); + } + if (snapshot.connectionState != ConnectionState.done) return const Center(child: CircularProgressIndicator()); @@ -88,6 +93,24 @@ class _PlayerPageState extends State { ); } + Future _errorPlaying() async { + await showDialog( + context: super.context, + builder: (context) => AlertDialog( + title: const Text('Errore imprevisto'), + content: const Text('Si è verificato un errore durante la riproduzione, riprova più tardi.'), + actions: [ + TextButton( + onPressed: () => Navigator.of(super.context).pop(), + child: const Text('Torna indietro') + ) + ], + ) + ); + if(super.mounted) + Navigator.of(super.context).pop(); + } + void _exitPlayer() { this._exited = true; if(this._playerInfo.hasStarted)