List of usage examples for android.media MediaMetadata METADATA_KEY_DISPLAY_ICON
String METADATA_KEY_DISPLAY_ICON
To view the source code for android.media MediaMetadata METADATA_KEY_DISPLAY_ICON.
Click Source Link
From source file:org.opensilk.video.playback.PlaybackService.java
void updateMetadata() { assertCreated();//from ww w. j a va 2s . co m final Media media = mMediaPlayer.getMedia(); final MediaBrowser.MediaItem mediaItem = mDbClient.getMedia(media.getUri()); final MediaMetadata.Builder b = new MediaMetadata.Builder(); CharSequence title; Uri artworkUri = null; long duration; if (mediaItem != null) { MediaDescription description = mediaItem.getDescription(); title = description.getTitle(); b.putText(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, title); b.putText(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE, description.getSubtitle()); if (description.getIconUri() != null) { b.putText(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI, description.getIconUri().toString()); artworkUri = description.getIconUri(); } MediaMetaExtras metaExtras = MediaMetaExtras.from(description); b.putText(MediaMetadata.METADATA_KEY_TITLE, metaExtras.getMediaTitle()); duration = metaExtras.getDuration(); } else { title = media.getMeta(Media.Meta.Title); b.putText(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, title); String artworkUrl = media.getMeta(Media.Meta.ArtworkURL); if (!StringUtils.isEmpty(artworkUrl)) { b.putText(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI, artworkUrl); artworkUri = Uri.parse(artworkUrl); } duration = mMediaPlayer.getLength(); } b.putLong(MediaMetadata.METADATA_KEY_DURATION, duration); if (artworkUri != null) { RequestOptions options = new RequestOptions().fitCenter(mContext); FutureTarget<Bitmap> futureTarget = Glide.with(mContext).asBitmap().apply(options).load(artworkUri) .submit(); try { Bitmap bitmap = futureTarget.get(5000, TimeUnit.MILLISECONDS); b.putBitmap(MediaMetadata.METADATA_KEY_DISPLAY_ICON, bitmap); } catch (InterruptedException | ExecutionException | TimeoutException e) { //pass } } mMediaSession.setMetadata(b.build()); mMediaSession.setSessionActivity(makeActivityIntent(mediaItem)); }