mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
完善新播放逻辑
This commit is contained in:
parent
eb1955e5e6
commit
114c9761fd
30 changed files with 658 additions and 683 deletions
58
lib/features/player/core/player_status.dart
Normal file
58
lib/features/player/core/player_status.dart
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue