7

enter image description here

As you already know that Android Oreo introduced the new design for media controls, rather than selecting a singular color for the notification based on the app's color, media playback notifications can instead draw colors out of the album artwork. Android then uses those colors to make a notification that blends the artwork into the notification while making the notification itself pop in your notification shade.

May I know how we can do this ?

mob_web_dev
  • 2,342
  • 1
  • 20
  • 42
  • please help me for the same CHECK THE LINK https://stackoverflow.com/questions/54633202/how-to-set-mediaplayer-notification-with-mediasession-and-notificationcompat-med – Vipul Chauhan Feb 12 '19 at 14:59

2 Answers2

3

This is MediaStyle for Notification. You need to set MediaStyle and media session tokon and thats it. For example:

NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID);

//building some actions...

builder.setSmallIcon(R.mipmap.ic_launcher)
                .setStyle(new android.support.v4.media.app.NotificationCompat.MediaStyle()
                        .setShowActionsInCompactView(0, 1, 2)
                        .setShowCancelButton(true)
                        .setMediaSession(mediaSessionCompat.getSessionToken()))
                .setCategory(NotificationCompat.CATEGORY_TRANSPORT)
                .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
                .setShowWhen(false)
                .setContentTitle("Title Name")
                .setContentText("Content text")
                .setSmallIcon(R.drawable.pause)
                .setWhen(0)
                .setAutoCancel(true)
                .setLargeIcon(icon);

You can find tutorial here: Tutorial

Mateusz Kaflowski
  • 2,221
  • 1
  • 29
  • 35
0

https://developer.android.com/reference/android/app/Notification.Builder.html

To fill with solid colour:

.setColorized(boolean colorize)

Set whether this notification should be colorized.

-A media template lets the user control media currently playing from an app.

The collapsed view displays up to three actions, and the large icon can show a related image, such as an album cover.

The expanded view displays up to five actions with a larger image, or six actions if no image is displayed. Colors from provided images automatically color the notification's background and other elements. (https://material.io/guidelines/patterns/notifications.html#notifications-templates)

-Media notifications will automatically get colorized based on the album art. The Palette API takes the album art, extracts some colors, and applies it to the media player notification.

Skromak
  • 490
  • 6
  • 12
  • Apparently media notifications will automatically get colorized based on the album art. The Palette API takes the album art, extracts some colors, and applies it to the media player notification. – Skromak Mar 20 '18 at 11:03
  • 1
    https://developer.android.com/reference/android/support/v7/graphics/Palette.html https://developer.android.com/training/material/palette-colors.html – Skromak Mar 20 '18 at 11:04
  • But how the media control images are changing ? – mob_web_dev Mar 22 '18 at 06:05