mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Two fixes for setMetadata
This commit is contained in:
parent
f36fd2f7b2
commit
b2e2551e33
@ -1626,8 +1626,12 @@ public final class Player implements
|
||||
final boolean showThumbnail = prefs.getBoolean(
|
||||
context.getString(R.string.show_thumbnail_key), true);
|
||||
// setMetadata only updates the metadata when any of the metadata keys are null
|
||||
mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(),
|
||||
showThumbnail ? getThumbnail() : null, duration);
|
||||
if (showThumbnail) {
|
||||
mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(), getThumbnail(),
|
||||
duration);
|
||||
} else {
|
||||
mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(), duration);
|
||||
}
|
||||
}
|
||||
|
||||
private void startProgressLoop() {
|
||||
@ -3023,9 +3027,11 @@ public final class Player implements
|
||||
|
||||
@Nullable
|
||||
public Bitmap getThumbnail() {
|
||||
return currentThumbnail == null
|
||||
? BitmapFactory.decodeResource(context.getResources(), R.drawable.dummy_thumbnail)
|
||||
: currentThumbnail;
|
||||
if (currentThumbnail == null) {
|
||||
currentThumbnail = BitmapFactory.decodeResource(
|
||||
context.getResources(), R.drawable.dummy_thumbnail);
|
||||
}
|
||||
return currentThumbnail;
|
||||
}
|
||||
//endregion
|
||||
|
||||
|
@ -65,6 +65,39 @@ public class MediaSessionManager {
|
||||
return mediaSession.getSessionToken();
|
||||
}
|
||||
|
||||
public void setMetadata(final String title,
|
||||
final String artist,
|
||||
final long duration) {
|
||||
if (!mediaSession.isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
if (getMetadataTitle() == null) {
|
||||
Log.d(TAG, "N_getMetadataTitle: title == null");
|
||||
}
|
||||
if (getMetadataArtist() == null) {
|
||||
Log.d(TAG, "N_getMetadataArtist: artist == null");
|
||||
}
|
||||
if (getMetadataDuration() <= 1) {
|
||||
Log.d(TAG, "N_getMetadataDuration: duration <= 1; " + getMetadataDuration());
|
||||
}
|
||||
}
|
||||
|
||||
if (getMetadataTitle() == null || getMetadataArtist() == null || getMetadataDuration() <= 1
|
||||
|| !getMetadataTitle().equals(title)) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "setMetadata: N_Metadata update: t: " + title + " a: " + artist
|
||||
+ " d: " + duration);
|
||||
}
|
||||
|
||||
mediaSession.setMetadata(new MediaMetadataCompat.Builder()
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, title)
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, artist)
|
||||
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration).build());
|
||||
}
|
||||
}
|
||||
|
||||
public void setMetadata(final String title,
|
||||
final String artist,
|
||||
final Bitmap albumArt,
|
||||
|
Loading…
Reference in New Issue
Block a user