Open YogeshSinghPathania1 opened 1 year ago
But in some devices its working fine
This may be because these devices have different operating system versions. When you do this with a MediaSessionConnector
you have to make sure that this behaves the same on all API levels like for instance before and after Android 13.
From the screenshot and the info above, it looks like this is a notification on a device before Android 13. I may be wrong, but if this is the case, then the custom actions in the session have no impact on the action on the notification.
This includes that you keep the PlayerNotificationManager
or your app code that creates the notification for Android 12 and below in sync with what you do with custom actions in the session. Please find this document about how this behaves since Android 13.
@marcbaechinger I have already read the documentation for Android 13 updates. As per documentaion i have integrating the custom buttons through MediaSessionConnector
But the thing is, in Android 13, it works fine on some devices but not on others (Samsung S21, for example) . If you want more screen short . However, this should work for all devices.
I did not find any way to resolve this. Could you please explain how we ensure that this behaves consistently across all API levels?I did not find anything in the documentation regarding this issue. Please share any information or links. How can we control the position of the buttons?
I don't think I have more info than what is documented in the Android 13 changes that you already know: https://developer.android.com/about/versions/13/behavior-changes-13#playback-controls These are the guideline with which we implemented the custom commands of the Media3 session module to support notifications on all API levels (see https://github.com/androidx/media/issues/38).
I will test the Media3 implementation with a Samsung phone with Android 13 as soon as I get my hands on such a device.
From your code you posted this looks like what I would expect is required to do and as you say, it seems to work on some devices. So we can rule out that the MediaSessionConnector
is somehow buggy and changes the order of the custom actions (please correct me if you think this is different).
According to the doc linked above, it should work if the actions are in the correct order in the legacy/platform session. You can verify this by looking at what
adb shell dumpsys media_session
outputs for your session.
Yeah, you are right that Samsung is doing their own thing on Android 13.
Accordingly, what I know is about the same as you. The notification is apparently based on the media session as the custom action is replicated in the notification. However, the layout and the placing of buttons as for rewind/ffwd and custom actions is different from what vanilla Android does.
This is Galaxy S21 with Android 13
And this is what system UI of Android does without modification of the OEM:
You can imagine that I am as happy about this as you are. :(
This is obviously different and I do not have information about how Samsung draws the notification. Sorry I can not provide you with useful information about this as I simply just don't know. You may want to ask Samsung about it.
@marcbaechinger I'm facing the same problem and we made a dirty workaround for samsung devices that inverts the list of custom actions and looks woking but with some exceptions: if there is a single element o if there is a playlist (see attached video without implementing the fix).
It's so weird to see how the drawing mechanism is so inconsistent that even trying to implement a fix doesn't work... One of my guessings is, can we remove the previous/next icons from the playe? maybe that could make the icons more consistent?
As per the documentation I see that we can set them empty by:
PlaybackState [extras](https://developer.android.com/reference/android/media/session/PlaybackState#getExtras()) include a true boolean value for key SESSION_EXTRAS_KEY_SLOT_RESERVATION_SKIP_TO_PREV.
But I'm not sure how to do that with exoplayer, should be do it though MediaSessionConnector
? would it be possible to ask how can we do it?
Thank you!
Look in the video how when there is no "next" icon, the ff/rw icons are reversed but when both next/previous are present they look normal.
https://user-images.githubusercontent.com/2378636/224095538-e8f6f0cd-ac4c-4ed6-aac2-80a8427fbfdf.mp4
Many thanks for this. Very useful!
PlaybackState [extras](https://developer.android.com/reference/android/media/session/PlaybackState#getExtras()) include a true boolean value for key SESSION_EXTRAS_KEY_SLOT_RESERVATION_SKIP_TO_PREV. But I'm not sure how to do that with exoplayer,
Can you let me know how you produced the notification from above video?
When you use MediaSessionConnector
the you have access to the MediaSessionCompat
directly and can do this by calling sessionCompat.setExtras(Bundle)
. With Media3
you can do MediaSession.setExtras(Bundle)
and use mediaSession.setCustomLayout()
. Media3 takes care for all API levels (with the exception of this open issue with Samsung :(). There is a more detailed description of how you can do custom commands with Media3 here.
I have some question to your screencast: Is this done with Media3? If not, are the custom actions in the media session or are the buttons in the notification the notification actions that you've put into the Notification
when using the NotificationCompat.Builder
?
would it be possible to ask how can we do it?
I try to find out something.
@marcbaechinger I'm preparing a project with something similar of my implementation so you can take a look on it :) (I can't share the real project)
will try to do in the next few days.
(Internal bug-ref sent to Samsung: b/273221499)
Any update on the same from samsung? Can you share the bug report link if available?
Unfortunately no response yet.
Can you still repro this with the most recent Media3 version? If you can upload a screenshot and shortly describe this would be helpful. I can nudge again and see whether they give me a response. Until now I have no feedback unfortunately. My situation is not much better than yours to be honest. You may, as an alternative, find ways to file a bug directly on a Samsung site.
Can you still repro this with the most recent Media3 version?
@marcbaechinger Yes, I have the same or similar issue on Samsung devices running Android 13 and 14.
I just want to add the Seek back and Seek forward buttons as you mentioned here and on the OEM Android 13 it works as I would expect according to the documentation:
OEM Android
(OEM Android 13 - Playlist with action skip to next active)
(OEM Android 13 - Playlist with action skip to next inactive (last item or single item playlist))
Samsung
(Samsung Android 13,14 - Playlist with action skip to next active, not bad)
(compact mode)
BUT
(Samsung Android 13,14 - Playlist with action skip to next inactive (last item or single item playlist))
(compact mode)
Seek back and Seek forward buttons are swapped and compact mode looks weird :/
I tried to customize positions in the DefaultMediaNotificationProvider getMediaButtons() or addNotificationActions()
, but without change. I would temporarily be happy with the solution as you mentioned here (hide the action skip and previous and replace them with custom seek buttons), but I need to keep the skip and previous player functionality for in-app controls.
Still no response from Samsung?
I'm having a very similar issue with Android auto and custom media actions. When I am listening to a timeline which only has one media item, ExoPlayer does not render the Skip to next action. In that specific case, it reverses the order of my custom media actions for Fast-Forward and Rewind. Otherwise, the order is correct.
I get this same behaviour on both Samsung and Pixel devices, though I am unfortunately only able to test this via the DHU since I don't actually have a vehicle with Android auto. Also, I am using the latest version of ExoPlayer 2. Unfortunately I cannot yet migrate to 3 until the client wants to make time for that (not that this is anyone else's problem, just providing context).
I understand if this info isn't useful or you can't help, but I wanted to share this as it seemed relevant.
That's a long shot as this is more for SystemUi than for Auto. Have you tried reserving the seek to next button ('EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_NEXT')?
@OptIn(UnstableApi::class)
override fun onConnect(
session: MediaSession,
controller: MediaSession.ControllerInfo,
): MediaSession.ConnectionResult {
if (
session.isMediaNotificationController(controller)
) {
// Select the button to display.
val sessionExtras = Bundle()
sessionExtras.putBoolean(MediaConstants.EXTRAS_KEY_SLOT_RESERVATION_SEEK_TO_NEXT, true)
return MediaSession.ConnectionResult.AcceptedResultBuilder(session)
.setSessionExtras(sessionExtras)
.build()
}
// Default commands without media button preferences for common controllers.
return MediaSession.ConnectionResult.AcceptedResultBuilder(session).build()
}
I want to use custom next/previous actions instead of the native ones. So I started by removing the native ones by allowing only needed actions: But in some devices
As you observed, the buttons in the home section are inverted, how can I keep the same order as in the app? But in some devices its working fine Any idea how we can resolve this? @phhusson @xian @canatella @kiall @talklittle @marcbaechinger