mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Fix notification thumbnail pixelation on newer androids
This commit is contained in:
parent
d9403bf4da
commit
854651aa71
1 changed files with 13 additions and 2 deletions
|
@ -183,10 +183,12 @@ class MediaPlaybackService : Service() {
|
|||
Logger.v(TAG, "updateMediaSession");
|
||||
var isUpdating = false;
|
||||
val video: IPlatformVideo;
|
||||
var lastBitmap: Bitmap? = null
|
||||
if(videoUpdated == null) {
|
||||
val notifLastVideo = _notif_last_video ?: return;
|
||||
video = notifLastVideo;
|
||||
isUpdating = true;
|
||||
lastBitmap = _notif_last_bitmap;
|
||||
}
|
||||
else
|
||||
video = videoUpdated;
|
||||
|
@ -199,6 +201,7 @@ class MediaPlaybackService : Service() {
|
|||
.putString(MediaMetadata.METADATA_KEY_ARTIST, video.author.name)
|
||||
.putString(MediaMetadata.METADATA_KEY_TITLE, video.name)
|
||||
.putLong(MediaMetadata.METADATA_KEY_DURATION, video.duration * 1000)
|
||||
.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, lastBitmap)
|
||||
.build());
|
||||
|
||||
val thumbnail = video.thumbnails.getHQThumbnail();
|
||||
|
@ -212,10 +215,18 @@ class MediaPlaybackService : Service() {
|
|||
val tag = video;
|
||||
Glide.with(this).asBitmap()
|
||||
.load(thumbnail)
|
||||
.into(object: CustomTarget<Bitmap>() {
|
||||
.into(object: CustomTarget<Bitmap>(1200, 750) {
|
||||
override fun onResourceReady(resource: Bitmap,transition: Transition<in Bitmap>?) {
|
||||
if(tag == _notif_last_video)
|
||||
if(tag == _notif_last_video) {
|
||||
notifyMediaSession(video, resource)
|
||||
_mediaSession?.setMetadata(
|
||||
MediaMetadataCompat.Builder()
|
||||
.putString(MediaMetadata.METADATA_KEY_ARTIST, video.author.name)
|
||||
.putString(MediaMetadata.METADATA_KEY_TITLE, video.name)
|
||||
.putLong(MediaMetadata.METADATA_KEY_DURATION, video.duration * 1000)
|
||||
.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, resource)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
if(tag == _notif_last_video)
|
||||
|
|
Loading…
Add table
Reference in a new issue