Added support for showing feed item images on Android Auto
This commit is contained in:
parent
8d2df1afa1
commit
0ae6ca8d04
|
@ -5,6 +5,7 @@ import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.media.MediaMetadataRetriever;
|
import android.media.MediaMetadataRetriever;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -165,13 +166,20 @@ public class FeedMedia extends FeedFile implements Playable {
|
||||||
*/
|
*/
|
||||||
public MediaBrowserCompat.MediaItem getMediaItem() {
|
public MediaBrowserCompat.MediaItem getMediaItem() {
|
||||||
Playable p = this;
|
Playable p = this;
|
||||||
MediaDescriptionCompat description = new MediaDescriptionCompat.Builder()
|
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder()
|
||||||
.setMediaId(String.valueOf(id))
|
.setMediaId(String.valueOf(id))
|
||||||
.setTitle(p.getEpisodeTitle())
|
.setTitle(p.getEpisodeTitle())
|
||||||
.setDescription(p.getFeedTitle())
|
.setDescription(p.getFeedTitle())
|
||||||
.setSubtitle(p.getFeedTitle())
|
.setSubtitle(p.getFeedTitle());
|
||||||
.build();
|
if (item != null) {
|
||||||
return new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE);
|
// getImageLocation() also loads embedded images, which we can not send to external devices
|
||||||
|
if (item.getImageUrl() != null) {
|
||||||
|
builder.setIconUri(Uri.parse(item.getImageUrl()));
|
||||||
|
} else if (item.getFeed() != null && item.getFeed().getImageLocation() != null) {
|
||||||
|
builder.setIconUri(Uri.parse(item.getFeed().getImageLocation()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new MediaBrowserCompat.MediaItem(builder.build(), MediaBrowserCompat.MediaItem.FLAG_PLAYABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue