Fix wrong thumbnail in notification on Android 13 #8899
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is it?
Description of the changes in your PR
This PR fixes yet another issue about the notification thumbnail not changing when going to the previous or next item in the player queue (see #8890 (comment)).
What I think the problem was (though this might need more investigation) is this:
onBuffering
, which triggers a notification update for NewPipecurrentItem
) but rather on the StreamInfo (currentMetadata
) and thecurrentThumbnail
stored in the player. That StreamInfo, though, still belongs to the previous item in the queue, since stream details have not finished loading yet. This causes the wrong title, uploader and thumbnail to be temporarily set in the notification.So in the PR that will merge
NotificationUtil
andNotificationPlayerUi
, the notification, the player and the media session should be switched to using data not about the player StreamInfo, but rather the actual current play queue item (except for the thumbnail, for which we need the high-res one from the fully-loaded stream details). Though it might not be this simple.This PR fixes the problem by detecting when the queue item changes and then setting
currentThumbnail
tonull
. This happens in-between points 1 and 2 above, i.e. before the exoPlayer internal queue is synced and before the notification update is triggered.The commits strictly necessary to solve the issue are the first two, though the other two are also important in my opinion.
Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
Due diligence