use of android.support.v4.media.MediaDescriptionCompat in project NewPipe by TeamNewPipe.
the class BasePlayerMediaSession method getQueueMetadata.
@Override
public MediaDescriptionCompat getQueueMetadata(int index) {
if (player.getPlayQueue() == null || player.getPlayQueue().getItem(index) == null) {
return null;
}
final PlayQueueItem item = player.getPlayQueue().getItem(index);
MediaDescriptionCompat.Builder descriptionBuilder = new MediaDescriptionCompat.Builder().setMediaId(String.valueOf(index)).setTitle(item.getTitle()).setSubtitle(item.getUploader());
final Uri thumbnailUri = Uri.parse(item.getThumbnailUrl());
if (thumbnailUri != null)
descriptionBuilder.setIconUri(thumbnailUri);
return descriptionBuilder.build();
}
use of android.support.v4.media.MediaDescriptionCompat in project react-native-track-player by react-native-kit.
the class MediaNotification method updateMetadata.
public void updateMetadata(MediaMetadataCompat metadata) {
MediaDescriptionCompat description = metadata.getDescription();
// Fill notification info
nb.setContentTitle(description.getTitle());
nb.setContentText(description.getSubtitle());
nb.setSubText(description.getDescription());
nb.setLargeIcon(description.getIconBitmap());
// Update the notification
update();
}
use of android.support.v4.media.MediaDescriptionCompat in project AntennaPod by AntennaPod.
the class PlaybackService method createBrowsableMediaItemForFeed.
private MediaBrowserCompat.MediaItem createBrowsableMediaItemForFeed(Feed feed) {
MediaDescriptionCompat.Builder builder = new MediaDescriptionCompat.Builder().setMediaId("FeedId:" + feed.getId()).setTitle(feed.getTitle()).setDescription(feed.getDescription()).setSubtitle(feed.getCustomTitle());
if (feed.getImageUrl() != null) {
builder.setIconUri(Uri.parse(feed.getImageUrl()));
}
if (feed.getLink() != null) {
builder.setMediaUri(Uri.parse(feed.getLink()));
}
MediaDescriptionCompat description = builder.build();
return new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE);
}
use of android.support.v4.media.MediaDescriptionCompat in project AntennaPod by AntennaPod.
the class PlaybackService method createBrowsableMediaItem.
private MediaBrowserCompat.MediaItem createBrowsableMediaItem(@StringRes int title, @DrawableRes int icon, int numEpisodes) {
Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE).authority(getResources().getResourcePackageName(icon)).appendPath(getResources().getResourceTypeName(icon)).appendPath(getResources().getResourceEntryName(icon)).build();
MediaDescriptionCompat description = new MediaDescriptionCompat.Builder().setIconUri(uri).setMediaId(getResources().getString(title)).setTitle(getResources().getString(title)).setSubtitle(getResources().getQuantityString(R.plurals.num_episodes, numEpisodes, numEpisodes)).build();
return new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE);
}
use of android.support.v4.media.MediaDescriptionCompat in project Douya by DreaminginCodeZH.
the class MediaNotification method buildNotification.
private Notification buildNotification() {
MediaControllerCompat controller = mMediaSession.getController();
MediaMetadataCompat metadata = controller.getMetadata();
MediaDescriptionCompat description = metadata.getDescription();
NotificationCompat.Builder builder = new NotificationCompat.Builder(mService, mChannelId).setContentTitle(description.getTitle()).setContentText(description.getSubtitle()).setSubText(description.getDescription());
Bitmap largeIcon = description.getIconBitmap();
if (largeIcon == null) {
largeIcon = BitmapUtils.drawableToBitmap(AppCompatResources.getDrawable(mService, R.drawable.default_album_art));
}
builder.setLargeIcon(largeIcon).setContentIntent(controller.getSessionActivity()).setDeleteIntent(MediaButtonReceiver.makePendingIntent(mService, PlaybackStateCompat.ACTION_STOP)).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setSmallIcon(mSmallIconRes).setColor(ContextCompat.getColor(mService, mColorRes));
builder.setShowWhen(false);
boolean isPlaying = mIsPlaying.getAsBoolean();
builder.setOngoing(isPlaying).addAction(new NotificationCompat.Action(R.drawable.skip_to_previous_icon_white_24dp, mService.getString(R.string.media_action_skip_to_previous), MediaButtonReceiver.makePendingIntent(mService, PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS))).addAction(new NotificationCompat.Action(isPlaying ? R.drawable.pause_icon_white_24dp : R.drawable.play_icon_white_24dp, mService.getString(isPlaying ? R.string.media_action_pause : R.string.media_action_play), MediaButtonReceiver.makePendingIntent(mService, isPlaying ? PlaybackStateCompat.ACTION_PAUSE : PlaybackStateCompat.ACTION_PLAY))).addAction(new NotificationCompat.Action(R.drawable.skip_to_next_icon_white_24dp, mService.getString(R.string.media_action_skip_to_next), MediaButtonReceiver.makePendingIntent(mService, PlaybackStateCompat.ACTION_SKIP_TO_NEXT))).setStyle(new androidx.media.app.NotificationCompat.MediaStyle().setMediaSession(mMediaSession.getSessionToken()).setShowActionsInCompactView(0, 1, 2).setShowCancelButton(true).setCancelButtonIntent(MediaButtonReceiver.makePendingIntent(mService, PlaybackStateCompat.ACTION_STOP)));
return builder.build();
}
Aggregations