Skip to content

Commit

Permalink
applied ryanheise#812
Browse files Browse the repository at this point in the history
  • Loading branch information
appinteractive committed Apr 1, 2024
1 parent 6952be5 commit 555e945
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions just_audio/lib/just_audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,16 @@ class AudioPlayer {
return duration;
} on PlatformException catch (e) {
try {
// cant connect to servers
if (e.code == "-1004" && source is LockCachingAudioSource) {
// proxy is offline
try {
await _proxy._server.close(force: true);
} catch (_) {
// ignore err
}
await _proxy.start();
}
throw PlayerException(int.parse(e.code), e.message,
(e.details as Map<dynamic, dynamic>?)?.cast<String, dynamic>());
} on FormatException catch (_) {
Expand Down Expand Up @@ -2093,9 +2103,14 @@ class _ProxyHttpServer {
}
}, onDone: () {
_running = false;
}, onError: (Object e, StackTrace st) {
}, onError: (Object e, StackTrace st) async {
_running = false;
});
try {
await _server.close(force: true);
} catch (_) {
// ignore
}
}, cancelOnError: true);
}

/// Stops the server
Expand Down

0 comments on commit 555e945

Please sign in to comment.