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

How change the icons from lockscreen? #6544

Closed
matheusbrandao opened this issue Oct 14, 2019 · 10 comments
Closed

How change the icons from lockscreen? #6544

matheusbrandao opened this issue Oct 14, 2019 · 10 comments
Assignees

Comments

@matheusbrandao
Copy link

I want to change or disable the player icons on the lock screen, as shown below. How can I do this?

Screenshot_20191014-151226_Pronto

@marcbaechinger
Copy link
Contributor

For my pixel device with Q the lock screen shows the notification in the same way as it is displayed in the notification drawer.

So you can enable/disable buttons like documented in the class level JavaDoc of the PlayerNotificationManager.

To change the icons you can override the drawables used by the PlayerNotificationManager. The easiest way to do this is to place drawables with the same id in your project. The build process will then merge the resources and your resource will be packaged into the APK instead of the those from the ui module of the library.

To for instance have your own play button you can create a drawable with name exo_notification_play in you project. You should provide drawables for all resolutions.

@matheusbrandao
Copy link
Author

Yes, in my Moto Z Play the same thing that you reported happens. The lock screen shows the notification in the same way as it is displayed in the notification drawer.

However, testing on A8 appears these icons also as shown in the image. View resolving code mediaSession.isActive = true to mediaSession.isActive = false.

So these "extra icons" no longer appear on the lock screen.

@marcbaechinger
Copy link
Contributor

In case you are using the media session for lock screen only, you can try to disable the previous/next playback actions.

You can disable previous/next actions of the media session by _not_using a QueueNavigator. However, this may be not desired for other use cases you are having to solve with the MediaSession.

@matheusbrandao
Copy link
Author

How could I disable the media session next action?

@marcbaechinger
Copy link
Contributor

marcbaechinger commented Oct 22, 2019

The QueueNavigator has a method getSupportedQueueNavigatorActions which returns the actions supported by the queue navigator. If you are using the TimelineQueueNavigator it returns the following bitmask by default and if appropriate:

PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM
    | PlaybackStateCompat.ACTION_SKIP_TO_NEXT
    | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS

You can override getSupportedQueueNavigatorActions to return 0 to completely disable navigation and still provide the MediaDescriptionCompat objects to populate the queue.

@matheusbrandao
Copy link
Author

This works to disable or enable features.

What I wanted was not to show the next and previous buttons. But it didn't go away with your suggestion.

@marcbaechinger
Copy link
Contributor

Are you are saying that both, removing the ACTION_SKIP_ actions in the MediaSessionConnector and disabling the skipping in the PlayerNotificationManager did not remove the skip forward/backward buttons on the lockscreen?

For which device does it work and for which does it not work?

@matheusbrandao
Copy link
Author

In fact what is happening:

  • API 26 and below show no controls on the lock screen, only notifications.
  • In API 28 shows the controls in the notifications and in addition another controller in the lock screen. This one from the lock screen I can't get out of. I am testing on a samsung A8. Through MediaSessionConnector I was only able to disable the buttons but not hide them.

Below are images as it appears on A8 and as it appears in notifications:

A8 with API 28:
66773502-84f99e00-ee95-11e9-8947-eef04de44e8a

Moto Z Play with API 26 ():
Screenshot_20191028-101632

Screenshot_20191028-101918

@marcbaechinger
Copy link
Contributor

marcbaechinger commented Nov 15, 2019

I got my hand on a Samsung device to test. You are correct, there is no way to remove the buttons for navigating to the next/previous item.

According to my testing, that's a bug in the implementation of Samsung:

  1. Notification: Not including prev/next actions in the notification
  2. Media Session: Do not advertise ACTION_SKIP_TO_QUEUE_ITEM, ACTION_SKIP_TO_NEXT and ACTION_SKIP_TO_PREVIOUS
  3. Media session: Limit the queue size to a single media item (pass 1 to constructor of TimelineQueueNavigator)
  4. Not setting a queu at all (not setting a TimelineQueueNavigator)

Even when doing all the above at the same time the buttons are still visible. They are disabled but still there. That's exactly what you observed as well.

So even when we advise clients of the media session, that we are not having a queue or don't want them to navigate, the Samsung lock screen is showing the navigation buttons. I don't think there is much we can do about it then.

You probably want to file a bug against Samsung implementation of the lock screen. I don't have experience with that but I think you can do this here: https://developer.samsung.com/home.do Up to you, you can link to this issue here, so it should be not much work explaining. I'm happy to answer Samsung engineer's questions here in case.

@matheusbrandao
Copy link
Author

matheusbrandao commented Dec 6, 2019

Thank you so much for your answer.

I solved my problem like this (for now):
mediaSession.isActive = Build.VERSION.SDK_INT < Build.VERSION_CODES.O

This is because in versions above 8.0 mediaSession is automatically activated. In the versions below it is necessary to activate. With this the lock screen problem does not happen.

@ojw28 ojw28 closed this as completed Jun 11, 2020
@google google locked and limited conversation to collaborators Aug 11, 2020
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

4 participants