Two fixes for setMetadata
This commit is contained in:
parent
f36fd2f7b2
commit
b2e2551e33
2 changed files with 44 additions and 5 deletions
|
@ -1626,8 +1626,12 @@ public final class Player implements
|
||||||
final boolean showThumbnail = prefs.getBoolean(
|
final boolean showThumbnail = prefs.getBoolean(
|
||||||
context.getString(R.string.show_thumbnail_key), true);
|
context.getString(R.string.show_thumbnail_key), true);
|
||||||
// setMetadata only updates the metadata when any of the metadata keys are null
|
// setMetadata only updates the metadata when any of the metadata keys are null
|
||||||
mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(),
|
if (showThumbnail) {
|
||||||
showThumbnail ? getThumbnail() : null, duration);
|
mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(), getThumbnail(),
|
||||||
|
duration);
|
||||||
|
} else {
|
||||||
|
mediaSessionManager.setMetadata(getVideoTitle(), getUploaderName(), duration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startProgressLoop() {
|
private void startProgressLoop() {
|
||||||
|
@ -3023,9 +3027,11 @@ public final class Player implements
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Bitmap getThumbnail() {
|
public Bitmap getThumbnail() {
|
||||||
return currentThumbnail == null
|
if (currentThumbnail == null) {
|
||||||
? BitmapFactory.decodeResource(context.getResources(), R.drawable.dummy_thumbnail)
|
currentThumbnail = BitmapFactory.decodeResource(
|
||||||
: currentThumbnail;
|
context.getResources(), R.drawable.dummy_thumbnail);
|
||||||
|
}
|
||||||
|
return currentThumbnail;
|
||||||
}
|
}
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,39 @@ public class MediaSessionManager {
|
||||||
return mediaSession.getSessionToken();
|
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,
|
public void setMetadata(final String title,
|
||||||
final String artist,
|
final String artist,
|
||||||
final Bitmap albumArt,
|
final Bitmap albumArt,
|
||||||
|
|
Loading…
Reference in a new issue