31 lines
691 B
Dart
31 lines
691 B
Dart
// Author: fengshengxiong
|
|
// Date: 2024/5/8
|
|
// Description: 音乐数据盒子
|
|
|
|
import 'package:tone_snap/data/enum/play_mode.dart';
|
|
import 'package:tone_snap/data/storage/hive_storage.dart';
|
|
|
|
class MusicBox {
|
|
MusicBox._();
|
|
|
|
static final MusicBox _instance = MusicBox._();
|
|
|
|
factory MusicBox() {
|
|
return _instance;
|
|
}
|
|
|
|
/// 声明盒子
|
|
/// 注意, main函数中这个盒子已经打开, 可以进行存储操作
|
|
final _box = getMusicBox();
|
|
|
|
/// 设置播放模式
|
|
Future<void> putPlayMode(PlayMode playMode) {
|
|
return _box.put('play_mode', playMode);
|
|
}
|
|
|
|
/// 获取播放模式
|
|
PlayMode getPlayMode() {
|
|
return _box.get('play_mode') ?? PlayMode.listLoop;
|
|
}
|
|
}
|