Search in sources :

Example 11 with MediaDescriptionCompat

use of android.support.v4.media.MediaDescriptionCompat in project AntennaPod by AntennaPod.

the class FeedMedia method getMediaItem.

/**
     * Returns a MediaItem representing the FeedMedia object.
     * This is used by the MediaBrowserService
     */
public MediaBrowserCompat.MediaItem getMediaItem() {
    Playable p = this;
    MediaDescriptionCompat description = new MediaDescriptionCompat.Builder().setMediaId(String.valueOf(id)).setTitle(p.getEpisodeTitle()).setDescription(p.getFeedTitle()).setSubtitle(p.getFeedTitle()).build();
    return new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE);
}
Also used : Playable(de.danoeh.antennapod.core.util.playback.Playable) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Example 12 with MediaDescriptionCompat

use of android.support.v4.media.MediaDescriptionCompat in project android-UniversalMusicPlayer by googlesamples.

the class MediaNotificationManager method createNotification.

private Notification createNotification() {
    LogHelper.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata);
    if (mMetadata == null || mPlaybackState == null) {
        return null;
    }
    MediaDescriptionCompat description = mMetadata.getDescription();
    String fetchArtUrl = null;
    Bitmap art = null;
    if (description.getIconUri() != null) {
        // This sample assumes the iconUri will be a valid URL formatted String, but
        // it can actually be any valid Android Uri formatted String.
        // async fetch the album art icon
        String artUrl = description.getIconUri().toString();
        art = AlbumArtCache.getInstance().getBigImage(artUrl);
        if (art == null) {
            fetchArtUrl = artUrl;
            // use a placeholder art while the remote art is being downloaded
            art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.ic_default_art);
        }
    }
    // Notification channels are only supported on Android O+.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        createNotificationChannel();
    }
    final NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService, CHANNEL_ID);
    final int playPauseButtonPosition = addActions(notificationBuilder);
    notificationBuilder.setStyle(new MediaStyle().setShowActionsInCompactView(playPauseButtonPosition).setShowCancelButton(true).setCancelButtonIntent(mStopIntent).setMediaSession(mSessionToken)).setDeleteIntent(mStopIntent).setColor(mNotificationColor).setSmallIcon(R.drawable.ic_notification).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setOnlyAlertOnce(true).setContentIntent(createContentIntent(description)).setContentTitle(description.getTitle()).setContentText(description.getSubtitle()).setLargeIcon(art);
    if (mController != null && mController.getExtras() != null) {
        String castName = mController.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST);
        if (castName != null) {
            String castInfo = mService.getResources().getString(R.string.casting_to_device, castName);
            notificationBuilder.setSubText(castInfo);
            notificationBuilder.addAction(R.drawable.ic_close_black_24dp, mService.getString(R.string.stop_casting), mStopCastIntent);
        }
    }
    setNotificationPlaybackState(notificationBuilder);
    if (fetchArtUrl != null) {
        fetchBitmapFromURLAsync(fetchArtUrl, notificationBuilder);
    }
    return notificationBuilder.build();
}
Also used : Bitmap(android.graphics.Bitmap) MediaStyle(android.support.v4.media.app.NotificationCompat.MediaStyle) NotificationCompat(android.support.v4.app.NotificationCompat) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Example 13 with MediaDescriptionCompat

use of android.support.v4.media.MediaDescriptionCompat in project react-native-track-player by react-native-kit.

the class Track method toQueueItem.

public QueueItem toQueueItem() {
    if (queueItem != null)
        return queueItem;
    MediaDescriptionCompat desc = new MediaDescriptionCompat.Builder().setMediaId(id).setMediaUri(url).setTitle(title).setSubtitle(artist).setDescription(description).setIconUri(artwork).build();
    queueItem = new QueueItem(desc, queueId);
    return queueItem;
}
Also used : QueueItem(android.support.v4.media.session.MediaSessionCompat.QueueItem) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat)

Example 14 with MediaDescriptionCompat

use of android.support.v4.media.MediaDescriptionCompat in project Signal-Android by WhisperSystems.

the class VoiceNoteQueueNavigator method getMediaDescription.

@Override
@NonNull
public MediaDescriptionCompat getMediaDescription(@NonNull Player player, int windowIndex) {
    MediaItem mediaItem = windowIndex >= 0 && windowIndex < player.getMediaItemCount() ? player.getMediaItemAt(windowIndex) : null;
    if (mediaItem == null || mediaItem.playbackProperties == null) {
        return EMPTY;
    }
    MediaDescriptionCompat mediaDescriptionCompat = (MediaDescriptionCompat) mediaItem.playbackProperties.tag;
    if (mediaDescriptionCompat == null) {
        return EMPTY;
    }
    return mediaDescriptionCompat;
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) MediaDescriptionCompat(android.support.v4.media.MediaDescriptionCompat) NonNull(androidx.annotation.NonNull)

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