From 886835f12899a85ab8a76ef91bf15f2c8ac1eb02 Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sat, 22 Oct 2022 16:11:56 +0100 Subject: [PATCH] Added metadata to lockscreen. Closes #1470. --- .../libretube/util/NowPlayingNotification.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 aec065c26..afb1444e0 100644 --- a/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt +++ b/app/src/main/java/com/github/libretube/util/NowPlayingNotification.kt @@ -8,6 +8,7 @@ import android.content.Intent import android.graphics.Bitmap import android.graphics.drawable.BitmapDrawable import android.os.Build +import android.support.v4.media.MediaDescriptionCompat import android.support.v4.media.session.MediaSessionCompat import coil.request.ImageRequest import com.github.libretube.api.obj.Streams @@ -18,6 +19,7 @@ import com.github.libretube.ui.activities.MainActivity import com.google.android.exoplayer2.ExoPlayer import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector +import com.google.android.exoplayer2.ext.mediasession.TimelineQueueNavigator import com.google.android.exoplayer2.ui.PlayerNotificationManager class NowPlayingNotification( @@ -169,6 +171,19 @@ class NowPlayingNotification( setUseFastForwardActionInCompactView(true) setUseRewindActionInCompactView(true) } + mediaSessionConnector = MediaSessionConnector(mediaSession) + mediaSessionConnector.setQueueNavigator(object : TimelineQueueNavigator(mediaSession) { + override fun getMediaDescription( + player: Player, + windowIndex: Int + ): MediaDescriptionCompat { + return MediaDescriptionCompat.Builder().apply { + setTitle(streams?.title!!) + setSubtitle(streams?.uploader) + }.build() + } + }) + mediaSessionConnector.setPlayer(player) } /**