List of usage examples for android.media MediaMetadata METADATA_KEY_ART
String METADATA_KEY_ART
To view the source code for android.media MediaMetadata METADATA_KEY_ART.
Click Source Link
From source file:hkapps.playmxtv.Activities.PlaybackOverlayActivity.java
private void updateMetadata(final Ficha movie) { final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder(); String title = movie.getTitle().replace("_", " -"); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, title); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE, movie.getSinopsis()); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI, movie.getPoster()); // And at minimum the title and artist for legacy support metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, title); //metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, movie.); Glide.with(this).load(Uri.parse(movie.getPoster())).asBitmap().into(new SimpleTarget<Bitmap>(500, 500) { @Override/*ww w . j a va 2s . c o m*/ public void onResourceReady(Bitmap bitmap, GlideAnimation anim) { metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap); mSession.setMetadata(metadataBuilder.build()); } }); }
From source file:uk.org.ngo.squeezer.service.SqueezeService.java
/** * Manages the state of any ongoing notification based on the player and connection state. *///w ww.java 2s .c o m private void updateOngoingNotification() { Player activePlayer = this.mActivePlayer.get(); PlayerState activePlayerState = getActivePlayerState(); // Update scrobble state, if either we're currently scrobbling, or we // were (to catch the case where we started scrobbling a song, and the // user went in to settings to disable scrobbling). if (scrobblingEnabled || scrobblingPreviouslyEnabled) { scrobblingPreviouslyEnabled = scrobblingEnabled; Scrobble.scrobbleFromPlayerState(this, activePlayerState); } // If there's no active player then kill the notification and get out. // TODO: Have a "There are no connected players" notification text. if (activePlayer == null || activePlayerState == null) { clearOngoingNotification(); return; } boolean playing = activePlayerState.isPlaying(); // If the song is not playing and the user wants notifications only when playing then // kill the notification and get out. if (!playing && !mShowNotificationWhenNotPlaying) { clearOngoingNotification(); return; } // If there's no current song then kill the notification and get out. // TODO: Have a "There's nothing playing" notification text. final Song currentSong = activePlayerState.getCurrentSong(); if (currentSong == null) { clearOngoingNotification(); return; } // Compare the current state with the state when the notification was last updated. // If there are no changes (same song, same playing state) then there's nothing to do. String songName = currentSong.getName(); String albumName = currentSong.getAlbumName(); String artistName = currentSong.getArtist(); Uri url = currentSong.getArtworkUrl(); String playerName = activePlayer.getName(); if (mNotifiedPlayerState == null) { mNotifiedPlayerState = new PlayerState(); } else { boolean lastPlaying = mNotifiedPlayerState.isPlaying(); Song lastNotifiedSong = mNotifiedPlayerState.getCurrentSong(); // No change in state if (playing == lastPlaying && currentSong.equals(lastNotifiedSong)) { return; } } mNotifiedPlayerState.setCurrentSong(currentSong); mNotifiedPlayerState.setPlayStatus(activePlayerState.getPlayStatus()); final NotificationManagerCompat nm = NotificationManagerCompat.from(this); PendingIntent nextPendingIntent = getPendingIntent(ACTION_NEXT_TRACK); PendingIntent prevPendingIntent = getPendingIntent(ACTION_PREV_TRACK); PendingIntent playPendingIntent = getPendingIntent(ACTION_PLAY); PendingIntent pausePendingIntent = getPendingIntent(ACTION_PAUSE); PendingIntent closePendingIntent = getPendingIntent(ACTION_CLOSE); Intent showNowPlaying = new Intent(this, NowPlayingActivity.class) .setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); PendingIntent pIntent = PendingIntent.getActivity(this, 0, showNowPlaying, 0); Notification notification; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { final Notification.Builder builder = new Notification.Builder(this); builder.setContentIntent(pIntent); builder.setSmallIcon(R.drawable.squeezer_notification); builder.setVisibility(Notification.VISIBILITY_PUBLIC); builder.setShowWhen(false); builder.setContentTitle(songName); builder.setContentText(albumName); builder.setSubText(playerName); builder.setStyle(new Notification.MediaStyle().setShowActionsInCompactView(1, 2) .setMediaSession(mMediaSession.getSessionToken())); final MediaMetadata.Builder metaBuilder = new MediaMetadata.Builder(); metaBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, artistName); metaBuilder.putString(MediaMetadata.METADATA_KEY_ALBUM, albumName); metaBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, songName); mMediaSession.setMetadata(metaBuilder.build()); // Don't set an ongoing notification, otherwise wearable's won't show it. builder.setOngoing(false); builder.setDeleteIntent(closePendingIntent); if (playing) { builder.addAction( new Notification.Action(R.drawable.ic_action_previous, "Previous", prevPendingIntent)) .addAction(new Notification.Action(R.drawable.ic_action_pause, "Pause", pausePendingIntent)) .addAction(new Notification.Action(R.drawable.ic_action_next, "Next", nextPendingIntent)); } else { builder.addAction( new Notification.Action(R.drawable.ic_action_previous, "Previous", prevPendingIntent)) .addAction(new Notification.Action(R.drawable.ic_action_play, "Play", playPendingIntent)) .addAction(new Notification.Action(R.drawable.ic_action_next, "Next", nextPendingIntent)); } ImageFetcher.getInstance(this).loadImage(url, getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_width), getResources().getDimensionPixelSize(android.R.dimen.notification_large_icon_height), new ImageWorker.ImageWorkerCallback() { @Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) public void process(Object data, @Nullable Bitmap bitmap) { if (bitmap == null) { bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon_album_noart); } metaBuilder.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, bitmap); metaBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap); mMediaSession.setMetadata(metaBuilder.build()); builder.setLargeIcon(bitmap); nm.notify(PLAYBACKSERVICE_STATUS, builder.build()); } }); } else { NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setOngoing(true); builder.setCategory(NotificationCompat.CATEGORY_SERVICE); builder.setSmallIcon(R.drawable.squeezer_notification); RemoteViews normalView = new RemoteViews(this.getPackageName(), R.layout.notification_player_normal); RemoteViews expandedView = new RemoteViews(this.getPackageName(), R.layout.notification_player_expanded); normalView.setOnClickPendingIntent(R.id.next, nextPendingIntent); expandedView.setOnClickPendingIntent(R.id.previous, prevPendingIntent); expandedView.setOnClickPendingIntent(R.id.next, nextPendingIntent); builder.setContent(normalView); normalView.setTextViewText(R.id.trackname, songName); normalView.setTextViewText(R.id.albumname, albumName); expandedView.setTextViewText(R.id.trackname, songName); expandedView.setTextViewText(R.id.albumname, albumName); expandedView.setTextViewText(R.id.player_name, playerName); if (playing) { normalView.setImageViewResource(R.id.pause, R.drawable.ic_action_pause); normalView.setOnClickPendingIntent(R.id.pause, pausePendingIntent); expandedView.setImageViewResource(R.id.pause, R.drawable.ic_action_pause); expandedView.setOnClickPendingIntent(R.id.pause, pausePendingIntent); } else { normalView.setImageViewResource(R.id.pause, R.drawable.ic_action_play); normalView.setOnClickPendingIntent(R.id.pause, playPendingIntent); expandedView.setImageViewResource(R.id.pause, R.drawable.ic_action_play); expandedView.setOnClickPendingIntent(R.id.pause, playPendingIntent); } builder.setContentTitle(songName); builder.setContentText(getString(R.string.notification_playing_text, playerName)); builder.setContentIntent(pIntent); notification = builder.build(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notification.bigContentView = expandedView; } nm.notify(PLAYBACKSERVICE_STATUS, notification); ImageFetcher.getInstance(this).loadImage(this, url, normalView, R.id.album, getResources().getDimensionPixelSize(R.dimen.album_art_icon_normal_notification_width), getResources().getDimensionPixelSize(R.dimen.album_art_icon_normal_notification_height), nm, PLAYBACKSERVICE_STATUS, notification); ImageFetcher.getInstance(this).loadImage(this, url, expandedView, R.id.album, getResources().getDimensionPixelSize(R.dimen.album_art_icon_expanded_notification_width), getResources().getDimensionPixelSize(R.dimen.album_art_icon_expanded_notification_height), nm, PLAYBACKSERVICE_STATUS, notification); } }
From source file:de.kraenksoft.c3tv.ui.PlaybackOverlayFragment.java
private void updateMetadata(final Video video) { final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder(); metadataBuilder.putString(MediaMetadata.METADATA_KEY_MEDIA_ID, video.id + ""); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, video.title); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE, video.studio); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_DESCRIPTION, video.description); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI, video.cardImageUrl); metadataBuilder.putLong(MediaMetadata.METADATA_KEY_DURATION, mDuration); // And at minimum the title and artist for legacy support metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, video.title); metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, video.studio); Glide.with(this).load(Uri.parse(video.cardImageUrl)).asBitmap().into(new SimpleTarget<Bitmap>(500, 500) { @Override// w ww .j a v a2s .c o m public void onResourceReady(Bitmap bitmap, GlideAnimation anim) { metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap); mSession.setMetadata(metadataBuilder.build()); } }); }
From source file:org.mythtv.android.presentation.view.fragment.TvPlaybackOverlayFragment.java
private void updateMetadata(final VideoModel videoModel) { final MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder(); metadataBuilder.putString(MediaMetadata.METADATA_KEY_MEDIA_ID, videoModel.id + ""); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, videoModel.title); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE, videoModel.studio); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_DESCRIPTION, videoModel.description); metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI, videoModel.cardImageUrl); metadataBuilder.putLong(MediaMetadata.METADATA_KEY_DURATION, mDuration); // And at minimum the title and artist for legacy support metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, videoModel.title); metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, videoModel.studio); Glide.with(this).load(Uri.parse(videoModel.cardImageUrl)).asBitmap() .into(new SimpleTarget<Bitmap>(500, 500) { @Override/* www .j a v a 2 s .com*/ public void onResourceReady(Bitmap bitmap, GlideAnimation anim) { metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap); mSession.setMetadata(metadataBuilder.build()); } }); }
From source file:com.android.tv.MainActivity.java
private void updateMediaMetadata(String title, Bitmap posterArt) { MediaMetadata.Builder builder = new MediaMetadata.Builder(); builder.putString(MediaMetadata.METADATA_KEY_TITLE, title); if (posterArt != null) { builder.putBitmap(MediaMetadata.METADATA_KEY_ART, posterArt); }/*from ww w .j av a 2 s.c om*/ mMediaSession.setMetadata(builder.build()); }