When I use the Audio_service package in Flutter on my Android 11 device, clicking the playback pause button in the Flutter UI is valid, but clicking the buttons other than the pause button in the notification bar button is valid, and the notification bar buttons will not update after clicking the pause button I tried printing the value of playbackState.value.controls but it is correct [{androidIcon: drawable/audio_service_skip_previous, label: Previous, action: 4}, {androidIcon: drawable/audio_service_play_arrow, label: Play, action: 2}, { androidIcon: drawable/audio_service_skip_next, label: Next, action: 5}], the printed result is the play button but the pause button is still displayed in the notification bar, and the pause operation will still be performed after clicking
This is my code
@override
Future<void> stop() async {
print(playbackState.value.controls);
playbackState.add(playbackState.value
.copyWith(playing: false, controls: [MediaControl.skipToPrevious, MediaControl.play, MediaControl.skipToNext]));
await player?.stop();
print(playbackState.value.controls);
}
@override
Future<void> seek(Duration position) async {
player?.seek(position);
print(playbackState.value.controls);
}
@override
Future<void> play() async {
if (player == null) {
if (curindex != null) {
playnew(curindex!);
}
} else {
playbackState.add(playbackState.value.copyWith(
playing: true,
controls: [MediaControl.skipToPrevious, MediaControl.pause, MediaControl.skipToNext, MediaControl.stop],
));
await player?.play();
}
}
@override
Future<void> pause() async {
playbackState.add(playbackState.value.copyWith(
playing: false,
controls: [MediaControl.skipToPrevious, MediaControl.play, MediaControl.skipToNext],
));
await player?.pause();
}
[Video][https://download.kstore.space/download/2816/Screenrecording_20230812_154235.mp4]