Fix thumbnail sometimes not set to media session metadata

The thumbnail was not being updated in the media session metadata after it was loaded, since there was no metadata update in that case, only a notification update.
This commit is contained in:
Stypox 2022-07-21 22:44:59 +02:00 committed by litetex
parent bc33322d4b
commit 3cc43e9fb9

View file

@ -1,9 +1,11 @@
package org.schabi.newpipe.player.mediasession; package org.schabi.newpipe.player.mediasession;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.support.v4.media.session.MediaSessionCompat; import android.support.v4.media.session.MediaSessionCompat;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamInfo;
@ -60,6 +62,12 @@ public class MediaSessionPlayerUi extends PlayerUi {
); );
} }
@Override
public void onThumbnailLoaded(@Nullable final Bitmap bitmap) {
super.onThumbnailLoaded(bitmap);
player.getCurrentStreamInfo().ifPresent(this::onMetadataChanged);
}
public void handleMediaButtonIntent(final Intent intent) { public void handleMediaButtonIntent(final Intent intent) {
if (mediaSessionManager != null) { if (mediaSessionManager != null) {
mediaSessionManager.handleMediaButtonIntent(intent); mediaSessionManager.handleMediaButtonIntent(intent);