当前位置: 首页>>代码示例>>Java>>正文


Java MediaDescriptionCompat.getIconUri方法代码示例

本文整理汇总了Java中android.support.v4.media.MediaDescriptionCompat.getIconUri方法的典型用法代码示例。如果您正苦于以下问题:Java MediaDescriptionCompat.getIconUri方法的具体用法?Java MediaDescriptionCompat.getIconUri怎么用?Java MediaDescriptionCompat.getIconUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.media.MediaDescriptionCompat的用法示例。


在下文中一共展示了MediaDescriptionCompat.getIconUri方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fetchImage

import android.support.v4.media.MediaDescriptionCompat; //导入方法依赖的package包/类
private void fetchImage(@NonNull MediaDescriptionCompat description)
{
    String artUrl = null;
    if (description.getIconUri() != null) {
        artUrl = description.getIconUri().toString();
    }
    LogHelper.e(TAG, "fetchImage called ");
    if (!TextUtils.equals(artUrl, mArtUrl)) {
        mArtUrl = artUrl;
        Picasso.with(getActivity())
                .load(mArtUrl)
                .centerCrop()
                .fit()
                .into(videoThumbnail);
    }
}
 
开发者ID:teocci,项目名称:YouTube-In-Background,代码行数:17,代码来源:PlaybackControlsFragment.java

示例2: onLoad

import android.support.v4.media.MediaDescriptionCompat; //导入方法依赖的package包/类
@Override
protected void onLoad(Bundle savedInstanceState) {
    super.onLoad(savedInstanceState);
    subscriptions.clear();
    MediaDescriptionCompat desc = queueItem.getDescription();
    getView().trackTitle.setText(desc.getTitle());
    getView().artistName.setText(desc.getSubtitle());
    Bitmap artwork = desc.getIconBitmap();
    Uri artworkUri = desc.getIconUri();
    if (artwork != null) {
        getView().artworkThumbnail.setImageBitmap(artwork);
    } else if (artworkUri != null) {
        artworkReqestor.newRequest(artworkUri, getView().artworkThumbnail, null);
    } else {
        getView().artworkThumbnail.setImageResource(R.drawable.default_artwork);
    }
    updatePlayBtn();
    subscribeBroadcasts();
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:20,代码来源:FooterPageScreenPresenter.java

示例3: onBindViewHolder

import android.support.v4.media.MediaDescriptionCompat; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    QueueItem item = getItem(position);
    holder.reset();
    MediaDescriptionCompat desc = item.getDescription();
    holder.title.setText(desc.getTitle());
    holder.subtitle.setText(desc.getSubtitle());
    Uri uri = desc.getIconUri();
    if (uri != null) {
        ArtInfo artInfo = ArtInfo.fromUri(uri);
        if (artInfo !=ArtInfo.NULLINSTANCE) {
            requestor.newRequest(artInfo, holder.artwork, BundleHelper.b().putInt(1).get());
        } else {
            CharSequence titlee = desc.getTitle();
            setLetterTileDrawable(holder, titlee != null ? titlee.toString() : "");
        }
    }
    setItemActive(holder, item);
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:20,代码来源:QueueScreenViewAdapter.java

示例4: mapToMetadata

import android.support.v4.media.MediaDescriptionCompat; //导入方法依赖的package包/类
/**
 * Converts a {@link MediaDescriptionCompat} into {@link MediaMetadataCompat}. Only a title,
 * description, and media id will be converted. A subclass should override this method if their
 * {@link #map(Object)} method stores more data in the mapped MediaDescriptionCompat.
 *
 * @param item to be converted.
 * @return A converted MediaMetadataCompact from MediaDescriptionCompat.
 */
@NonNull
public MediaMetadataCompat mapToMetadata(MediaDescriptionCompat item) {
    MediaMetadataCompat.Builder builder =
            new MediaMetadataCompat.Builder()
                    .putText(MediaMetadataCompat.METADATA_KEY_TITLE, item.getTitle())
                    .putText(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, item.getTitle())
                    .putText(
                            MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION,
                            item.getDescription())
                    .putBitmap(
                            MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, item.getIconBitmap())
                    .putText(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, item.getMediaId());

    if (item.getIconUri() != null) {
        builder.putString(
                MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI,
                item.getIconUri().toString());
    }

    Bundle extras = item.getExtras();
    if (extras != null) {
        String backgroundArtUri = extras.getString(EXTRA_BACKGROUND_ART);
        if (backgroundArtUri != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_ART_URI, backgroundArtUri);
        }
    }

    return builder.build();
}
 
开发者ID:googlesamples,项目名称:leanback-assistant,代码行数:38,代码来源:ListPlaylistAdapter.java

示例5: createMediaNotification

import android.support.v4.media.MediaDescriptionCompat; //导入方法依赖的package包/类
@CheckResult @Nullable Notification createMediaNotification(
    @NonNull MediaMetadataCompat metadata) {
  MediaDescriptionCompat description = metadata.getDescription();
  NotificationCompat.Builder builder = new NotificationCompat.Builder(appContext);
  NotificationCompat.MediaStyle style = new NotificationCompat.MediaStyle().setCancelButtonIntent(
      MediaButtonReceiver.buildMediaButtonPendingIntent(appContext,
          PlaybackStateCompat.ACTION_PAUSE))
      .setShowCancelButton(true)
      .setShowActionsInCompactView(new int[] { 0, 1, 2 })
      .setMediaSession(Checker.checkNonNull(sessionToken));

  boolean isPlaying = playbackManager.isPlaying();
  @DrawableRes int playPauseIcon =
      isPlaying ? R.drawable.ic_pause_24dp : R.drawable.ic_play_arrow_24dp;
  String playPauseText = isPlaying ? "Pause" : "Play";
  builder.setColor(notificationColor)
      .addAction(R.drawable.ic_track_previous_24dp, "Previous", null)
      .addAction(playPauseIcon, playPauseText, null)
      .addAction(R.drawable.ic_track_next_24dp, "Next", null)
      .setSmallIcon(R.drawable.ic_notif_play_24dp)
      .setContentTitle(description.getTitle())
      .setContentText(description.getSubtitle())
      .setSubText(description.getDescription())
      .setContentIntent(PendingIntent.getActivity(appContext, 0, intent, 0))
      .setDeleteIntent(MediaButtonReceiver.buildMediaButtonPendingIntent(appContext,
          PlaybackStateCompat.ACTION_STOP))
      .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
      .setStyle(style);

  Uri icon = description.getIconUri();
  if (icon != null) {
    bitmapLoaded = LoaderHelper.unload(bitmapLoaded);
    bitmapLoaded = ImageLoader.fromLoader(bitmapLoader.newLoader().setFilePath(icon))
        .into(new BitmapTarget() {
          @Override public int getWidth() {
            return 64;
          }

          @Override public int getHeight() {
            return 64;
          }

          @Override public void loadImage(@NonNull Bitmap bitmap) {
            builder.setLargeIcon(bitmap);
            notificationManager.notify(NOTIFICATION_ID, builder.build());
          }
        });
  }
  return builder.build();
}
 
开发者ID:pyamsoft,项目名称:dontsuck-mp,代码行数:51,代码来源:NotificationSession.java

示例6: createNotification

import android.support.v4.media.MediaDescriptionCompat; //导入方法依赖的package包/类
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()
                    // show only play/pause in compact view
                    .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();
}
 
开发者ID:googlesamples,项目名称:android-UniversalMusicPlayer,代码行数:69,代码来源:MediaNotificationManager.java

示例7: createNotification

import android.support.v4.media.MediaDescriptionCompat; //导入方法依赖的package包/类
private Notification createNotification() {
    LogUtils.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata);
    if (mMetadata == null || mPlaybackState == null) {
        return null;
    }

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService);
    int playPauseButtonPosition = 0;

    // If skip to previous action is enabled
    if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) {
        notificationBuilder.addAction(R.drawable.ic_skip_previous_white_24dp,
                mService.getString(R.string.label_previous), mPreviousIntent);

        // If there is a "skip to previous" button, the play/pause button will
        // be the second one. We need to keep track of it, because the MediaStyle notification
        // requires to specify the index of the buttons (actions) that should be visible
        // when in compact view.
        playPauseButtonPosition = 1;
    }

    addPlayPauseAction(notificationBuilder);

    // If skip to next action is enabled
    if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) {
        notificationBuilder.addAction(R.drawable.ic_skip_next_white_24dp,
                mService.getString(R.string.label_next), mNextIntent);
    }

    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 || art.isRecycled()) {
            fetchArtUrl = artUrl;
            // use a placeholder art while the remote art is being downloaded
            art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.ic_default_art);
        }
    }

    notificationBuilder
            .setStyle(new NotificationCompat.MediaStyle()
                    .setShowActionsInCompactView(
                            new int[]{playPauseButtonPosition})  // show only play/pause in compact view
                    .setMediaSession(mSessionToken))
            .setColor(mNotificationColor)
            .setSmallIcon(R.drawable.ic_notification)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setUsesChronometer(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();
}
 
开发者ID:markzhai,项目名称:LyricHere,代码行数:79,代码来源:MediaNotificationManager.java

示例8: updateMediaSessionMetadata

import android.support.v4.media.MediaDescriptionCompat; //导入方法依赖的package包/类
private void updateMediaSessionMetadata() {
  if (doMaintainMetadata) {
    MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
    if (player != null && player.isPlayingAd()) {
      builder.putLong(MediaMetadataCompat.METADATA_KEY_ADVERTISEMENT, 1);
    }
    builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, player == null ? 0
        : player.getDuration() == C.TIME_UNSET ? -1 : player.getDuration());

    if (queueNavigator != null) {
      long activeQueueItemId = queueNavigator.getActiveQueueItemId(player);
      List<MediaSessionCompat.QueueItem> queue = mediaController.getQueue();
      for (int i = 0; queue != null && i < queue.size(); i++) {
        MediaSessionCompat.QueueItem queueItem = queue.get(i);
        if (queueItem.getQueueId() == activeQueueItemId) {
          MediaDescriptionCompat description = queueItem.getDescription();
          Bundle extras = description.getExtras();
          if (extras != null) {
            for (String key : extras.keySet()) {
              Object value = extras.get(key);
              if (value instanceof String) {
                builder.putString(metadataExtrasPrefix + key, (String) value);
              } else if (value instanceof CharSequence) {
                builder.putText(metadataExtrasPrefix + key, (CharSequence) value);
              } else if (value instanceof Long) {
                builder.putLong(metadataExtrasPrefix + key, (Long) value);
              } else if (value instanceof Integer) {
                builder.putLong(metadataExtrasPrefix + key, (Integer) value);
              } else if (value instanceof Bitmap) {
                builder.putBitmap(metadataExtrasPrefix + key, (Bitmap) value);
              } else if (value instanceof RatingCompat) {
                builder.putRating(metadataExtrasPrefix + key, (RatingCompat) value);
              }
            }
          }
          if (description.getTitle() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE,
                String.valueOf(description.getTitle()));
          }
          if (description.getSubtitle() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE,
                String.valueOf(description.getSubtitle()));
          }
          if (description.getDescription() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION,
                String.valueOf(description.getDescription()));
          }
          if (description.getIconBitmap() != null) {
            builder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON,
                description.getIconBitmap());
          }
          if (description.getIconUri() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI,
                String.valueOf(description.getIconUri()));
          }
          if (description.getMediaId() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID,
                String.valueOf(description.getMediaId()));
          }
          if (description.getMediaUri() != null) {
            builder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_URI,
                String.valueOf(description.getMediaUri()));
          }
          break;
        }
      }
    }
    mediaSession.setMetadata(builder.build());
  }
}
 
开发者ID:y20k,项目名称:transistor,代码行数:71,代码来源:MediaSessionConnector.java


注:本文中的android.support.v4.media.MediaDescriptionCompat.getIconUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。