forked from florent37/Flutter-AssetsAudioPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.dart
48 lines (40 loc) · 1.17 KB
/
errors.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import 'assets_audio_player.dart';
import 'player_group.dart';
enum AssetsAudioPlayerErrorType { Network, Player }
class ErrorHandler {
final AssetsAudioPlayerError error;
final AssetsAudioPlayer player;
final Duration? currentPosition;
final Playlist? playlist;
final int? playlistIndex;
const ErrorHandler({
required this.error,
required this.player,
this.currentPosition,
this.playlist,
this.playlistIndex,
});
}
typedef AssetsAudioPlayerErrorHandler = Function(ErrorHandler errorHandler);
typedef AssetsAudioPlayerGroupErrorHandler = Function(
AssetsAudioPlayerGroup group, ErrorHandler errorHandler);
AssetsAudioPlayerErrorType parseAssetsAudioPlayerErrorType(String type) {
switch (type) {
case 'network':
return AssetsAudioPlayerErrorType.Network;
default:
return AssetsAudioPlayerErrorType.Player;
}
}
class AssetsAudioPlayerError {
final AssetsAudioPlayerErrorType errorType;
final String message;
const AssetsAudioPlayerError({
required this.errorType,
required this.message,
});
@override
String toString() {
return 'AssetsAudioPlayerError{errorType: $errorType, message: $message}';
}
}