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);
}
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();
}
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;
}
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;
}
Aggregations