Skip to content

Commit

Permalink
error message if something goes wrong during player querying
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonfra04 committed Aug 5, 2024
1 parent b9f644f commit 40e72fc
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/pages/player_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class _PlayerPageState extends State<PlayerPage> {
() => 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());

Expand All @@ -88,6 +93,24 @@ class _PlayerPageState extends State<PlayerPage> {
);
}

Future<void> _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)
Expand Down

0 comments on commit 40e72fc

Please sign in to comment.