完善新播放逻辑

This commit is contained in:
rang 2025-11-22 15:54:29 +08:00
parent eb1955e5e6
commit 114c9761fd
30 changed files with 658 additions and 683 deletions

View 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,
);
}
}