From d9cac31962cce3a5cc038bca5f32cca997111798 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Mon, 10 Oct 2022 12:38:24 -0700 Subject: [PATCH] notification --- .../asgardius/page/s3manager/VideoPlayer.java | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java b/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java index 198a280..1585376 100644 --- a/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java +++ b/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java @@ -1,11 +1,14 @@ package asgardius.page.s3manager; +import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import android.app.AppOpsManager; +import android.app.PendingIntent; import android.app.PictureInPictureParams; import android.content.Context; import android.content.pm.PackageManager; +import android.graphics.Bitmap; import android.net.Uri; import android.net.wifi.WifiManager; import android.os.Build; @@ -127,7 +130,8 @@ public class VideoPlayer extends AppCompatActivity { //player.setMediaItem(mediaItem); // Prepare the player. player.setPlayWhenReady(true); - //playerNotificationManager = new PlayerNotificationManager.Builder(this, notificationId, "playback").build(); + playerNotificationManager = new PlayerNotificationManager.Builder(this, notificationId, "playback").build(); + playerNotificationManager.setPlayer(player); player.setMediaSource(mediaSource); player.prepare(); // Start the playback. @@ -326,4 +330,43 @@ public class VideoPlayer extends AppCompatActivity { super.onBackPressed(); } } + + private class DescriptionAdapter implements + PlayerNotificationManager.MediaDescriptionAdapter { + + @Override + public String getCurrentContentTitle(Player player) { + int window = player.getCurrentMediaItemIndex(); + return getTitle().toString(); + } + + @Nullable + @Override + public String getCurrentContentText(Player player) { + int window = player.getCurrentMediaItemIndex(); + return getCurrentContentText(player); + } + + @Nullable + @Override + public Bitmap getCurrentLargeIcon(Player player, + PlayerNotificationManager.BitmapCallback callback) { + int window = player.getCurrentMediaItemIndex(); + Bitmap largeIcon = getCurrentLargeIcon(player, callback); + /*if (largeIcon == null && getLargeIconUri(window) != null) { + // load bitmap async + loadBitmap(getLargeIconUri(window), callback); + return getPlaceholderBitmap(); + }*/ + return largeIcon; + } + + @Nullable + @Override + public PendingIntent createCurrentContentIntent(Player player) { + int window = player.getCurrentMediaItemIndex(); + //return createPendingIntent(window); + return null; + } + } } \ No newline at end of file