25 lines
640 B
Dart
25 lines
640 B
Dart
import 'package:flutter/material.dart';
|
|
import '../models/song_model.dart';
|
|
|
|
// 这是一个 ChangeNotifier,以后用来刷新底部的迷你播放条
|
|
class AudioService extends ChangeNotifier {
|
|
Song? _currentSong;
|
|
bool _isPlaying = false;
|
|
|
|
Song? get currentSong => _currentSong;
|
|
bool get isPlaying => _isPlaying;
|
|
|
|
// 占位方法:以后这里会调用 media_kit
|
|
void playSong(Song song) {
|
|
_currentSong = song;
|
|
_isPlaying = true;
|
|
notifyListeners(); // 刷新 UI
|
|
print('🎵 准备播放: ${song.title} - ${song.artist}');
|
|
}
|
|
|
|
void togglePlay() {
|
|
_isPlaying = !_isPlaying;
|
|
notifyListeners();
|
|
}
|
|
}
|