mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-18 07:19:34 +00:00
完善新播放逻辑
This commit is contained in:
parent
eb1955e5e6
commit
114c9761fd
30 changed files with 658 additions and 683 deletions
40
lib/features/player/providers/player_status_provider.dart
Normal file
40
lib/features/player/providers/player_status_provider.dart
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:vaani/features/player/core/player_status.dart' as core;
|
||||
|
||||
part 'player_status_provider.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class PlayerStatus extends _$PlayerStatus {
|
||||
@override
|
||||
core.PlayerStatus build() {
|
||||
return core.PlayerStatus();
|
||||
}
|
||||
|
||||
void setPlayStatus(core.PlayStatus playStatus) {
|
||||
state = state.copyWith(playStatus: playStatus);
|
||||
}
|
||||
|
||||
void setPlayStatusQuietly(core.PlayStatus playStatus) {
|
||||
// state.copyWith(quite: true);
|
||||
setPlayStatus(playStatus);
|
||||
// state.copyWith(quite: false);
|
||||
}
|
||||
|
||||
// 校验原值, 不相同则更新
|
||||
void setPlayStatusVerify(core.PlayStatus playStatus) {
|
||||
if (state.playStatus != playStatus) {
|
||||
setPlayStatus(playStatus);
|
||||
}
|
||||
}
|
||||
|
||||
void setLoading(String itemId) {
|
||||
state = state.copyWith(
|
||||
playStatus: core.PlayStatus.loading,
|
||||
itemId: itemId,
|
||||
);
|
||||
}
|
||||
|
||||
void setHidden() {
|
||||
state = state.copyWith(playStatus: core.PlayStatus.hidden);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue