From 93c4732978b6bc6a229cfd898d3d81934c3098f5 Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sun, 23 Oct 2022 10:53:28 +0100 Subject: [PATCH] Added artist metadata to AOD. --- .../libretube/util/NowPlayingNotification.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt index 1c5aa7f27..3b7c3dcfc 100644 --- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt +++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt @@ -1,5 +1,6 @@ package com.github.libretube.util +import android.R.attr.data import android.annotation.SuppressLint import android.app.NotificationManager import android.app.PendingIntent @@ -10,7 +11,9 @@ import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.drawable.BitmapDrawable import android.os.Build +import android.os.Bundle import android.support.v4.media.MediaDescriptionCompat +import android.support.v4.media.MediaMetadataCompat import android.support.v4.media.session.MediaSessionCompat import coil.request.ImageRequest import com.github.libretube.R @@ -142,8 +145,16 @@ class NowPlayingNotification( return MediaDescriptionCompat.Builder().apply { setTitle(streams?.title!!) setSubtitle(streams?.uploader) - setIconBitmap(BitmapFactory.decodeResource( - Resources.getSystem(), R.drawable.ic_launcher_monochrome)) + val extras = Bundle() + val appIcon = BitmapFactory.decodeResource( + Resources.getSystem(), + R.drawable.ic_launcher_monochrome + ) + extras.putParcelable(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, appIcon) + extras.putString(MediaMetadataCompat.METADATA_KEY_TITLE, streams?.title!!) + extras.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, streams?.uploader) + setIconBitmap(appIcon) + setExtras(extras) }.build() } })