mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-04 23:30:52 +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");
|
Logger.v(TAG, "updateMediaSession");
|
||||||
var isUpdating = false;
|
var isUpdating = false;
|
||||||
val video: IPlatformVideo;
|
val video: IPlatformVideo;
|
||||||
|
var lastBitmap: Bitmap? = null
|
||||||
if(videoUpdated == null) {
|
if(videoUpdated == null) {
|
||||||
val notifLastVideo = _notif_last_video ?: return;
|
val notifLastVideo = _notif_last_video ?: return;
|
||||||
video = notifLastVideo;
|
video = notifLastVideo;
|
||||||
isUpdating = true;
|
isUpdating = true;
|
||||||
|
lastBitmap = _notif_last_bitmap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
video = videoUpdated;
|
video = videoUpdated;
|
||||||
|
@ -199,6 +201,7 @@ class MediaPlaybackService : Service() {
|
||||||
.putString(MediaMetadata.METADATA_KEY_ARTIST, video.author.name)
|
.putString(MediaMetadata.METADATA_KEY_ARTIST, video.author.name)
|
||||||
.putString(MediaMetadata.METADATA_KEY_TITLE, video.name)
|
.putString(MediaMetadata.METADATA_KEY_TITLE, video.name)
|
||||||
.putLong(MediaMetadata.METADATA_KEY_DURATION, video.duration * 1000)
|
.putLong(MediaMetadata.METADATA_KEY_DURATION, video.duration * 1000)
|
||||||
|
.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, lastBitmap)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
val thumbnail = video.thumbnails.getHQThumbnail();
|
val thumbnail = video.thumbnails.getHQThumbnail();
|
||||||
|
@ -212,10 +215,18 @@ class MediaPlaybackService : Service() {
|
||||||
val tag = video;
|
val tag = video;
|
||||||
Glide.with(this).asBitmap()
|
Glide.with(this).asBitmap()
|
||||||
.load(thumbnail)
|
.load(thumbnail)
|
||||||
.into(object: CustomTarget<Bitmap>() {
|
.into(object: CustomTarget<Bitmap>(1200, 750) {
|
||||||
override fun onResourceReady(resource: Bitmap,transition: Transition<in Bitmap>?) {
|
override fun onResourceReady(resource: Bitmap,transition: Transition<in Bitmap>?) {
|
||||||
if(tag == _notif_last_video)
|
if(tag == _notif_last_video) {
|
||||||
notifyMediaSession(video, resource)
|
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?) {
|
override fun onLoadCleared(placeholder: Drawable?) {
|
||||||
if(tag == _notif_last_video)
|
if(tag == _notif_last_video)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue