mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
59 lines
1.4 KiB
Dart
59 lines
1.4 KiB
Dart
|
|
enum PlayStatus { stopped, playing, paused, hidden, loading, completed }
|
||
|
|
|
||
|
|
class PlayerStatus {
|
||
|
|
PlayStatus playStatus;
|
||
|
|
String itemId;
|
||
|
|
bool quite;
|
||
|
|
|
||
|
|
PlayerStatus({
|
||
|
|
this.playStatus = PlayStatus.hidden,
|
||
|
|
this.itemId = '',
|
||
|
|
this.quite = false,
|
||
|
|
}) {
|
||
|
|
// addListener(_onStatusChanged);
|
||
|
|
}
|
||
|
|
bool isPlaying({String? itemId}) {
|
||
|
|
if (itemId != null && this.itemId.isNotEmpty) {
|
||
|
|
return playStatus == PlayStatus.playing && this.itemId == itemId;
|
||
|
|
} else {
|
||
|
|
return playStatus == PlayStatus.playing;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
bool isPaused({String? itemId}) {
|
||
|
|
if (itemId != null && this.itemId.isNotEmpty) {
|
||
|
|
return playStatus == PlayStatus.paused && this.itemId == itemId;
|
||
|
|
} else {
|
||
|
|
return playStatus == PlayStatus.paused;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
bool isStopped({String? itemId}) {
|
||
|
|
if (itemId != null && this.itemId.isNotEmpty) {
|
||
|
|
return playStatus == PlayStatus.stopped && this.itemId == itemId;
|
||
|
|
} else {
|
||
|
|
return playStatus == PlayStatus.stopped;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
bool isLoading(String? itemId) {
|
||
|
|
if (itemId != null && this.itemId.isNotEmpty) {
|
||
|
|
return playStatus == PlayStatus.loading && this.itemId == itemId;
|
||
|
|
} else {
|
||
|
|
return playStatus == PlayStatus.loading;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
PlayerStatus copyWith({
|
||
|
|
PlayStatus? playStatus,
|
||
|
|
String? itemId,
|
||
|
|
bool? quite,
|
||
|
|
}) {
|
||
|
|
return PlayerStatus(
|
||
|
|
playStatus: playStatus ?? this.playStatus,
|
||
|
|
itemId: itemId ?? this.itemId,
|
||
|
|
quite: quite ?? this.quite,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|