Core Freeze:核心链路功能已经完成设计,后续进入beta功能开发模式,接下来会在UI部分微调后,进入首个Release版本(1.1.0-Release)
This commit is contained in:
@@ -779,7 +779,6 @@ class AudioService extends ChangeNotifier {
|
|||||||
debugPrint('💾 [AudioService] playback state saved');
|
debugPrint('💾 [AudioService] playback state saved');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 恢复播放状态
|
|
||||||
/// 恢复播放状态
|
/// 恢复播放状态
|
||||||
Future<bool> restorePlaybackState() async {
|
Future<bool> restorePlaybackState() async {
|
||||||
final state = await _db.getPlaybackState();
|
final state = await _db.getPlaybackState();
|
||||||
@@ -803,7 +802,9 @@ class AudioService extends ChangeNotifier {
|
|||||||
|
|
||||||
_queue = queue;
|
_queue = queue;
|
||||||
_currentIndex = state['current_index'] as int;
|
_currentIndex = state['current_index'] as int;
|
||||||
if (_currentIndex >= _queue.length) _currentIndex = 0;
|
if (_currentIndex < 0 || _currentIndex >= _queue.length) {
|
||||||
|
_currentIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
final modeStr = state['play_mode'] as String? ?? 'sequential';
|
final modeStr = state['play_mode'] as String? ?? 'sequential';
|
||||||
_playMode = modeStr == 'sequential'
|
_playMode = modeStr == 'sequential'
|
||||||
@@ -813,6 +814,20 @@ class AudioService extends ChangeNotifier {
|
|||||||
: PlayMode.shuffle;
|
: PlayMode.shuffle;
|
||||||
_currentPlaylistId = state['current_playlist_id'] as String?;
|
_currentPlaylistId = state['current_playlist_id'] as String?;
|
||||||
|
|
||||||
|
// ⭐⭐⭐ 关键修复:重建 _shuffledIndices 和 _shuffledIndex ⭐⭐⭐
|
||||||
|
if (_playMode == PlayMode.shuffle) {
|
||||||
|
_shuffledIndices = List.generate(_queue.length, (i) => i);
|
||||||
|
_shuffledIndices.shuffle();
|
||||||
|
_shuffledIndex = _shuffledIndices.indexOf(_currentIndex);
|
||||||
|
if (_shuffledIndex == -1) {
|
||||||
|
_shuffledIndex = 0;
|
||||||
|
_currentIndex = _shuffledIndices[0];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_shuffledIndices = List.generate(_queue.length, (i) => i);
|
||||||
|
_shuffledIndex = _currentIndex;
|
||||||
|
}
|
||||||
|
|
||||||
// 保存待恢复的进度
|
// 保存待恢复的进度
|
||||||
final savedPos = state['position_ms'] as int? ?? 0;
|
final savedPos = state['position_ms'] as int? ?? 0;
|
||||||
_pendingSeekPosition = Duration(milliseconds: savedPos);
|
_pendingSeekPosition = Duration(milliseconds: savedPos);
|
||||||
@@ -821,10 +836,11 @@ class AudioService extends ChangeNotifier {
|
|||||||
_currentSong = song;
|
_currentSong = song;
|
||||||
_onSongChanged?.call(song);
|
_onSongChanged?.call(song);
|
||||||
|
|
||||||
debugPrint(
|
debugPrint('♻️ [AudioService] playback state restored: '
|
||||||
'♻️ [AudioService] playback state restored: ${song.title} - ${song.artist}');
|
'queue=${_queue.length}, index=$_currentIndex, '
|
||||||
|
'song=${song.title}, mode=$_playMode');
|
||||||
|
|
||||||
// ⭐ 关键:加载音频但不自动播放
|
// ⭐ 加载音频但不自动播放
|
||||||
await _loadRestoredPlayback();
|
await _loadRestoredPlayback();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user