diff --git a/lib/services/audio_player_handler.dart b/lib/services/audio_player_handler.dart index 83e7ceb..c3e7fb5 100644 --- a/lib/services/audio_player_handler.dart +++ b/lib/services/audio_player_handler.dart @@ -81,20 +81,29 @@ class AudioPlayerHandler extends audio_service.BaseAudioHandler { void _publishStateOnly() { final current = playbackState.value; - // ⭐ 使用类成员 _currentPosition,不再重复声明 - debugPrint( - '📡 [publishStateOnly] position=$_currentPosition, playing=${current.playing}'); - playbackState.add(audio_service.PlaybackState( - controls: current.controls.isNotEmpty - ? current.controls - : _state.playbackState.controls, - processingState: _state.playbackState.processingState, - playing: current.playing, - androidCompactActionIndices: current.androidCompactActionIndices, - updatePosition: _currentPosition, // ⭐ 尝试加上 - updateTime: DateTime.now(), - )); + debugPrint( + '📡 [publishStateOnly] position=$_currentPosition, playing=${current.playing}', + ); + + playbackState.add( + audio_service.PlaybackState( + controls: current.controls.isNotEmpty + ? current.controls + : _state.playbackState.controls, + processingState: _state.playbackState.processingState, + playing: current.playing, + androidCompactActionIndices: current.androidCompactActionIndices, + + // ⭐ 声明支持 seek + systemActions: const { + audio_service.MediaAction.seek, + }, + + updatePosition: _currentPosition, + updateTime: DateTime.now(), + ), + ); } void _updateMediaItem({