From c3271b07f12dfe7249ffbf43ecabe5959d5bc50d Mon Sep 17 00:00:00 2001 From: lxh2875931338 Date: Sun, 23 Aug 2026 19:03:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E8=BF=9E=E7=BB=AD=E6=92=AD?= =?UTF-8?q?=E6=94=BE=20+=20MediaItem=20+=20=E6=92=AD=E6=94=BE=E7=8A=B6?= =?UTF-8?q?=E6=80=81=20+=20=E5=AE=9E=E6=97=B6=E8=BF=9B=E5=BA=A6=20+=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=20seek=20+=20seek=20=E5=90=8E=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD=E5=AE=9E=E6=97=B6=E6=9B=B4=E6=96=B0=E5=9D=87=E5=B7=B2?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E8=BE=BE=E6=88=90=E7=9B=AE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/services/audio_player_handler.dart | 35 ++++++++++++++++---------- 1 file changed, 22 insertions(+), 13 deletions(-) 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({