Fixed artwork not updating when in audio only.

This commit is contained in:
Koen J
2026-02-10 15:08:43 +01:00
parent 4a08058322
commit 88950843b3
2 changed files with 33 additions and 14 deletions
@@ -216,6 +216,7 @@ class VideoDetailView : ConstraintLayout {
private val _playerProgress: PlayerControlView;
private val _timeBar: TimeBar;
private var _upNext: UpNextView;
private var _artworkTarget: CustomTarget<Bitmap>? = null
private val rootView: ConstraintLayout;
@@ -882,6 +883,9 @@ class VideoDetailView : ConstraintLayout {
};
onClose.subscribe {
_artworkTarget?.let { Glide.with(context).clear(it) }
_artworkTarget = null
_player.setArtwork(null)
checkAndRemoveWatchLater();
_lastVideoSource = null;
_lastAudioSource = null;
@@ -1264,6 +1268,9 @@ class VideoDetailView : ConstraintLayout {
fun onDestroy() {
Logger.i(TAG, "onDestroy");
_destroyed = true;
_artworkTarget?.let { Glide.with(context).clear(it) }
_artworkTarget = null
_player.setArtwork(null)
_taskLoadVideo.cancel();
_commentsList.cancel();
_player.clear();
@@ -2053,19 +2060,31 @@ class VideoDetailView : ConstraintLayout {
_player.switchToVideoMode()
isAudioOnlyUserAction = false;
} else {
val thumbnail = video.thumbnails.getHQThumbnail();
if ((videoSource == null) && !thumbnail.isNullOrBlank()) // || _player.isAudioMode
Glide.with(context).asBitmap().load(thumbnail).withMaxSizePx()
.into(object: CustomTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
_player.setArtwork(BitmapDrawable(resources, resource));
}
override fun onLoadCleared(placeholder: Drawable?) {
_player.setArtwork(null);
}
});
else
_player.setArtwork(null);
_artworkTarget?.let { Glide.with(context).clear(it) }
_artworkTarget = null
val thumbnail = video.thumbnails.getHQThumbnail()
val showArtwork = _player.isAudioMode || isAudioOnlyUserAction || (videoSource == null)
if (showArtwork && !thumbnail.isNullOrBlank()) {
val target = object : CustomTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
_player.setArtwork(BitmapDrawable(resources, resource))
}
override fun onLoadCleared(placeholder: Drawable?) {
_player.setArtwork(null)
}
}
_artworkTarget = target
Glide.with(context)
.asBitmap()
.load(thumbnail)
.withMaxSizePx()
.into(target)
} else {
_player.setArtwork(null)
}
}
fragment.lifecycleScope.launch(Dispatchers.Main) {
+1 -1
View File
@@ -542,7 +542,7 @@
<string name="restart_playback_when_gaining_connectivity_after_a_loss">Restart playback when gaining connectivity after a loss</string>
<string name="chapter_update_fps_title">Chapter Update FPS</string>
<string name="chapter_update_fps_description">Change accuracy of chapter updating, higher might cost more performance</string>
<string name="set_automatic_backup">Set Automatic Backup</string>
<string name="set_automatic_backup">Configure Automatic Backup</string>
<string name="shortly_after_opening_the_app_start_fetching_subscriptions">Shortly after opening the app, start fetching subscriptions</string>
<string name="show_faq">Show FAQ</string>
<string name="show_issues">Show Issues</string>