Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

there has play/pause control in notification not match the empty controls setting or not set controls #1099

Open
rd-wang opened this issue Nov 27, 2024 · 5 comments

Comments

@rd-wang
Copy link

rd-wang commented Nov 27, 2024

Documented behaviour

PlaybackState _transformEvent(PlaybackEvent event) {
    return PlaybackState(
      controls: [
        if (_player.playing)
          MediaControl.pause.copyWith(androidIcon: "drawable/baseline_forward_30_24")
        else
          MediaControl.play.copyWith(androidIcon: "drawable/baseline_forward_30_24"),
        MediaControl.stop.copyWith(androidIcon: "drawable/audio_service_pause"),
        MediaControl.rewind.copyWith(androidIcon: "drawable/audio_service_mute"),
        const MediaControl(
          androidIcon: 'drawable/baseline_forward_30_24',
          label: 'Fast Forward',
          action: MediaAction.fastForward,
        ),
        MediaControl.custom(
            androidIcon: 'drawable/ic_baseline_favorite_24',
            label: 'favorite',
            name: 'favorite',
            extras: <String, dynamic>{'level': 1}),
      ],
      systemActions: const {
        MediaAction.seek,
        MediaAction.stop,
        MediaAction.rewind,
        MediaAction.playPause,
        MediaAction.play,
        MediaAction.pause,
        MediaAction.seekForward,
        MediaAction.seekBackward,
      },

Actual behaviour

Question: How to replace the default play/pause icon in notification
Phenomenon:
Modify the button control in the notification in the controls parameter of PlaybackState, clear the list, and there will be a default play/pause icon switching function on the UI;

Add MediaControl.play with the same name but replace the iconMediaControl.play.copyWith(androidIcon: "drawable/baseline_forward_30_24") that displays the default icon;

Adding a picture with the same name as the default icon to the drawable cannot replace the default play and pause icons. But stop can be replaced.
The image is not modified: MediaControl.pause.copyWith(androidIcon: "drawable/audio_service_stop"),
Image modification: MediaControl.stop,
Image modification: MediaControl.rewind.copyWith(androidIcon: "drawable/audio_service_stop"),

Add a custom type of controls, and the icon can take effect normally.

In the example you provided, you can reproduce this problem by directly modifying the content in controls. No other modifications are required.

Minimal reproduction project

Official example: example_android13.dart

Reproduction steps

Modify the control parameter content in the _transformEvent method and add the corresponding test image to the drawable.

Output of flutter doctor

It has nothing to do with flutter

Devices exhibiting the bug

android 14 ,Huawei Honor pro9

@rd-wang
Copy link
Author

rd-wang commented Nov 27, 2024

https://developer.android.com/about/versions/13/behavior-changes-13?hl=zh-cn#playback-controls
Because slot 1 of android controls cannot be customized, the function of slot 1 cannot be modified?

@ryanheise
Copy link
Owner

Can you submit a bug report in English following the instructions?

@rd-wang
Copy link
Author

rd-wang commented Nov 27, 2024

Can you submit a bug report in English following the instructions?

sorry, I have modified the description。 maybe is not issue,but i have no idea for that。

@ryanheise
Copy link
Owner

If you want to ask a question about how set the icons on Android, please follow the instructions on the New Issue page which direct you to StackOverflow (the question asking/answering site). If you find the answer, hopefully it works for you. If you discover that you need me to expose more of the Android API in this plugin, you can come back here and submit a feature request detailing exactly what parts of the API are missing.

@rd-wang
Copy link
Author

rd-wang commented Nov 27, 2024

If you want to ask a question about how set the icons on Android, please follow the instructions on the New Issue page which direct you to StackOverflow (the question asking/answering site). If you find the answer, hopefully it works for you. If you discover that you need me to expose more of the Android API in this plugin, you can come back here and submit a feature request detailing exactly what parts of the API are missing.

this is a problem

when i clear controls setting or not set controls

PlaybackState(
controls:[],
...
)
PlaybackState(
...
)

there is a default pause and play icon in notification

this is because com/ryanheise/audioservice/AudioService.java line 75 AUTO_ENABLED_ACTIONS
set bitmask of the available capabilities.
| PlaybackStateCompat.ACTION_PAUSE
| PlaybackStateCompat.ACTION_PLAY
| PlaybackStateCompat.ACTION_PLAY_PAUSE
remove this bitmask
there is no controls in notification match the empty controls setting or not set controls

@rd-wang rd-wang changed the title can't delete play or pause button on notification, can't change icon for play and pause button there has play/pause control in notification not match the empty controls setting or not set controls Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants