Search in sources :

Example 6 with MediaDescriptionCompat

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();
}
Also used : PlayQueueItem(org.schabi.newpipe.playlist.PlayQueueItem) Uri(android.net.Uri) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Example 7 with MediaDescriptionCompat

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();
}
Also used : MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Example 8 with MediaDescriptionCompat

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);
}
Also used : MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Example 9 with MediaDescriptionCompat

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);
}
Also used : Uri(android.net.Uri) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Example 10 with MediaDescriptionCompat

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();
}
Also used : MediaMetadataCompat(android.support.v4.media.MediaMetadataCompat) Bitmap(android.graphics.Bitmap) NotificationCompat(androidx.core.app.NotificationCompat) MediaControllerCompat(android.support.v4.media.session.MediaControllerCompat) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Aggregations

MediaDescriptionCompat (android.support.v4.media.MediaDescriptionCompat)13 Bitmap (android.graphics.Bitmap)4 Uri (android.net.Uri)4 MediaMetadataCompat (android.support.v4.media.MediaMetadataCompat)3 MediaControllerCompat (android.support.v4.media.session.MediaControllerCompat)3 Drawable (android.graphics.drawable.Drawable)2 MediaSessionCompat (android.support.v4.media.session.MediaSessionCompat)2 Pair (android.support.v4.util.Pair)2 Palette (android.support.v7.graphics.Palette)2 PendingIntent (android.app.PendingIntent)1 Context (android.content.Context)1 Configuration (android.content.res.Configuration)1 AnimationDrawable (android.graphics.drawable.AnimationDrawable)1 Bundle (android.os.Bundle)1 RemoteException (android.os.RemoteException)1 NonNull (android.support.annotation.NonNull)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 MediaBrowserCompat (android.support.v4.media.MediaBrowserCompat)1 MediaStyle (android.support.v4.media.app.NotificationCompat.MediaStyle)1 QueueItem (android.support.v4.media.session.MediaSessionCompat.QueueItem)1