后台连续播放 + MediaItem + 播放状态 + 实时进度 + 系统 seek + seek 后继续实时更新均已正常达成目标
This commit is contained in:
@@ -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(
|
||||
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, // ⭐ 尝试加上
|
||||
|
||||
// ⭐ 声明支持 seek
|
||||
systemActions: const {
|
||||
audio_service.MediaAction.seek,
|
||||
},
|
||||
|
||||
updatePosition: _currentPosition,
|
||||
updateTime: DateTime.now(),
|
||||
));
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _updateMediaItem({
|
||||
|
||||
Reference in New Issue
Block a user