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

[Android] Advertise the action to seek to particular points in the playback state #127

Closed
hacker1024 opened this issue Dec 16, 2019 · 13 comments
Assignees

Comments

@hacker1024
Copy link
Contributor

hacker1024 commented Dec 16, 2019

Is your feature request related to a problem? Please describe.
Android 10 introduces seek bars in media notifications. To be interactive, the action bits must include PlaybackStateCompat.ACTION_SEEK_TO.

The problem is, the plugin only includes the notification button actions in the playback state, so Android doesn't know that seeking is supported, as there are no notification buttons that seek to a certain point.

Describe the solution you'd like
I propose that we separate the notification actions from the actions in the playback state. The AudioServiceBackground.setState function can be changed to have, perhaps, notificationControls and systemControls arguments. For the latter argument, we can copy the ACTION_* constants from the PlaybackStateCompat Android class, and they can be merged and passed through in a customisable way.

Describe alternatives you've considered
There are no alternatives without changing plugin code.

@ryanheise ryanheise self-assigned this Dec 17, 2019
@ryanheise
Copy link
Owner

Another way to see it is that each MediaControl switches on an action bit, but it only appears as a notification button if its androidIcon is set. All of the ACTION_ constants are already defined in the MediaAction enum. Would that solve your use case?

@hacker1024
Copy link
Contributor Author

That would, thanks. It might make the order of notification buttons a bit unclear, though.

@ryanheise
Copy link
Owner

True. I guess it does make sense to have a separate parameter to setState, although the additional list could just be a list of the enum type, like this:

  static Future<void> setState({
    @required List<MediaControl> controls,
    List<MediaAction> enabledActions,
    @required BasicPlaybackState basicState,
    int position = 0,
    double speed = 1.0,
    int updateTime,
    List<int> androidCompactActions,
  })

Not sure if there's a better name than enabledActions. The union of these two lists will be used to set the action bits, so the second list is only for the "additional" enabled actions that are not actually represented by notification buttons, so maybe even additionalActions.

@hacker1024
Copy link
Contributor Author

What about systemActions or publicActions or playbackActions?

@ryanheise
Copy link
Owner

I like systemActions, thanks for the suggestion. I've tested it in the example and it seems to work (see latest commit).

@hacker1024
Copy link
Contributor Author

hacker1024 commented Dec 18, 2019

That works perfectly, thanks.

@YaarPatandarAA
Copy link
Contributor

YaarPatandarAA commented Mar 5, 2020

That works perfectly, thanks.

How can I achieve this media notification style with the seek bar having a dot for sliding and the duration time? Also not overlapping the image.

@ryanheise
Copy link
Owner

Not sure, but it might be device specific? The standard media style notification is the one offered by the Android system itself, so conceivably different device manufacturers could have customised the style of their notifications and each device might look different.

@ryanheise
Copy link
Owner

Just to follow up on my previous answer, I should have mentioned that you should look at the included example as a starting point, because it demonstrates how to turn on the seek bar and the duration time. It's just that the positioning might be different on different devices.

@YaarPatandarAA
Copy link
Contributor

YaarPatandarAA commented Mar 6, 2020

I have the media notification working on Android and I see a seek bar in the notification however it is just a black bar with no Duration timestamp and no SeekBar Dot/Handle. I can tap on it and seek happens however it does not look like how that users sees it.

As far as my device, I have tested another flutter package that also generates a media notification but their notification generates it exactly like what the user above sees.

I don't know what the difference might be you guys are both using androidx.media.app.NotificationCompat.MediaStyle

Here are some articles that might help?
Android 10 features and APIs
Add Seekbar in MediaStyle notifications for Android 10 devices #6394

@YaarPatandarAA
Copy link
Contributor

I can take a look at it but right now I am trying to get this package working how I need it. This is not a major feature that I need at the moment.

@ryanheise
Copy link
Owner

I don't know as to the layout issue, but the duration information displayed in the notification comes from various places. The duration comes from the current media item so you have to include that data when you call AudioServiceBackground.setMediaItem and the current position comes the data you include in AudioServiceBackground.setState, so you should make sure you are setting the right data there.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with audio_service.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants