Reformatted MediaSessionManager code
This commit is contained in:
parent
c0d41661e8
commit
ba0876b43b
|
@ -93,36 +93,41 @@ public class MediaSessionManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkIfMetadataShouldBeSet(title, artist, optAlbumArt, duration)) {
|
if (!checkIfMetadataShouldBeSet(title, artist, optAlbumArt, duration)) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "setMetadata: N_Metadata update:"
|
Log.d(TAG, "setMetadata: No update required");
|
||||||
+ " t: " + title
|
|
||||||
+ " a: " + artist
|
|
||||||
+ " thumb: " + (
|
|
||||||
optAlbumArt.isPresent()
|
|
||||||
? optAlbumArt.get().hashCode()
|
|
||||||
: "<none>")
|
|
||||||
+ " d: " + duration);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder()
|
if (DEBUG) {
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, title)
|
Log.d(TAG, "setMetadata: N_Metadata update:"
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, artist)
|
+ " t: " + title
|
||||||
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration);
|
+ " a: " + artist
|
||||||
|
+ " thumb: " + (
|
||||||
|
optAlbumArt.isPresent()
|
||||||
|
? optAlbumArt.get().hashCode()
|
||||||
|
: "<none>")
|
||||||
|
+ " d: " + duration);
|
||||||
|
}
|
||||||
|
|
||||||
if (optAlbumArt.isPresent()) {
|
final MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder()
|
||||||
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, optAlbumArt.get());
|
.putString(MediaMetadataCompat.METADATA_KEY_TITLE, title)
|
||||||
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, optAlbumArt.get());
|
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, artist)
|
||||||
}
|
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration);
|
||||||
|
|
||||||
mediaSession.setMetadata(builder.build());
|
if (optAlbumArt.isPresent()) {
|
||||||
|
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, optAlbumArt.get());
|
||||||
|
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, optAlbumArt.get());
|
||||||
|
}
|
||||||
|
|
||||||
lastTitleHashCode = title.hashCode();
|
mediaSession.setMetadata(builder.build());
|
||||||
lastArtistHashCode = artist.hashCode();
|
|
||||||
lastDuration = duration;
|
lastTitleHashCode = title.hashCode();
|
||||||
if (optAlbumArt.isPresent()) {
|
lastArtistHashCode = artist.hashCode();
|
||||||
lastAlbumArtHashCode = optAlbumArt.get().hashCode();
|
lastDuration = duration;
|
||||||
}
|
if (optAlbumArt.isPresent()) {
|
||||||
|
lastAlbumArtHashCode = optAlbumArt.get().hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +149,7 @@ public class MediaSessionManager {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the current metadata is valid
|
// Check if the current metadata is valid
|
||||||
if (getMetadataTitle() == null
|
if (getMetadataTitle() == null
|
||||||
|| getMetadataArtist() == null
|
|| getMetadataArtist() == null
|
||||||
|
@ -163,6 +169,7 @@ public class MediaSessionManager {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we got an album art check if the current set AlbumArt is null
|
// If we got an album art check if the current set AlbumArt is null
|
||||||
if (optAlbumArt.isPresent() && getMetadataAlbumArt() == null) {
|
if (optAlbumArt.isPresent() && getMetadataAlbumArt() == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
|
Loading…
Reference in New Issue