當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaMetadataCompat.Builder方法代碼示例

本文整理匯總了Java中android.support.v4.media.MediaMetadataCompat.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaMetadataCompat.Builder方法的具體用法?Java MediaMetadataCompat.Builder怎麽用?Java MediaMetadataCompat.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.media.MediaMetadataCompat的用法示例。


在下文中一共展示了MediaMetadataCompat.Builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: notifyAyahChanged

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
private void notifyAyahChanged() {
  if (mAudioRequest != null) {
    Intent updateIntent = new Intent(AudioUpdateIntent.INTENT_NAME);
    updateIntent.putExtra(AudioUpdateIntent.STATUS, AudioUpdateIntent.PLAYING);
    updateIntent.putExtra(AudioUpdateIntent.SURA, mAudioRequest.getCurrentSura());
    updateIntent.putExtra(AudioUpdateIntent.AYAH, mAudioRequest.getCurrentAyah());
    mBroadcastManager.sendBroadcast(updateIntent);

    MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder()
        .putString(MediaMetadataCompat.METADATA_KEY_TITLE, mAudioRequest.getTitle(this));
    if (mPlayer.isPlaying()) {
      metadataBuilder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, mPlayer.getDuration());
    }

    if (mDisplayIcon != null) {
      metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, mDisplayIcon);
    }
    mMediaSession.setMetadata(metadataBuilder.build());
  }
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:21,代碼來源:AudioService.java

示例2: updateMetaData

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
/**
 * 更新正在播放的音樂信息,切換歌曲時調用
 */
public void updateMetaData(String path) {
    if (!StringUtils.isReal(path)) {
        mMediaSession.setMetadata(null);
        return;
    }

    SongInfo info = mediaManager.getSongInfo(context, path);
    MediaMetadataCompat.Builder metaData = new MediaMetadataCompat.Builder()
            .putString(MediaMetadataCompat.METADATA_KEY_TITLE, info.getTitle())
            .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, info.getArtist())
            .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, info.getAlbum())
            .putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, info.getArtist())
            .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, info.getDuration())
            .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, getCoverBitmap(info));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        metaData.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getCount());
    }

    mMediaSession.setMetadata(metaData.build());
}
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:25,代碼來源:MediaSessionManager.java

示例3: updateMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
public void updateMetadata(String trackTitle, String artist, String album, BitmapDrawable albumImage) {
    MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder()
            .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, artist)
            .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, album)
            .putString(MediaMetadataCompat.METADATA_KEY_TITLE, trackTitle)
            .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, -1);
    if (albumImage != null) {
        metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumImage.getBitmap());
    }
    mediaSession.setMetadata(metadataBuilder.build());
    mediaSession.setActive(true);

    // Put the service in the foreground, post notification
    Helpers.createStopNotification(mediaSession, MediaRecorderService.this, MediaRecorderService.class, NOTIFICATION_ID);

    // currently, only way to update Cast metadata is to re-send URL which causes reload of stream
    //castMedia(trackTitle, artist, album, imageUrl);
}
 
開發者ID:aschober,項目名稱:vinyl-cast,代碼行數:19,代碼來源:MediaRecorderService.java

示例4: getMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
public static MediaMetadataCompat getMetadata(Context ctx, String mediaId) {
    MediaMetadataCompat metadataWithoutBitmap = music.get(mediaId);
    Bitmap albumArt = getAlbumBitmap(ctx, mediaId);

    // Since MediaMetadataCompat is immutable, we need to create a copy to set the album art
    // We don't set it initially on all items so that they don't take unnecessary memory
    MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
    for (String key :
            new String[]{
                    MediaMetadataCompat.METADATA_KEY_MEDIA_ID,
                    MediaMetadataCompat.METADATA_KEY_ALBUM,
                    MediaMetadataCompat.METADATA_KEY_ARTIST,
                    MediaMetadataCompat.METADATA_KEY_GENRE,
                    MediaMetadataCompat.METADATA_KEY_TITLE
            }) {
        builder.putString(key, metadataWithoutBitmap.getString(key));
    }
    builder.putLong(
            MediaMetadataCompat.METADATA_KEY_DURATION,
            metadataWithoutBitmap.getLong(MediaMetadataCompat.METADATA_KEY_DURATION));
    builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt);
    return builder.build();
}
 
開發者ID:googlecodelabs,項目名稱:musicplayer-devices,代碼行數:24,代碼來源:MusicLibrary.java

示例5: getMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
public static MediaMetadataCompat getMetadata(Context ctx, String mediaId) {
    MediaMetadataCompat metadataWithoutBitmap = music.get(mediaId);
    Bitmap albumArt = getAlbumBitmap(ctx, mediaId);

    // Since MediaMetadataCompat is immutable, we need to create a copy to set the album art.
    // We don't set it initially on all items so that they don't take unnecessary memory.
    MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
    for (String key :
            new String[] {
                MediaMetadataCompat.METADATA_KEY_MEDIA_ID,
                MediaMetadataCompat.METADATA_KEY_ALBUM,
                MediaMetadataCompat.METADATA_KEY_ARTIST,
                MediaMetadataCompat.METADATA_KEY_GENRE,
                MediaMetadataCompat.METADATA_KEY_TITLE
            }) {
        builder.putString(key, metadataWithoutBitmap.getString(key));
    }
    builder.putLong(
            MediaMetadataCompat.METADATA_KEY_DURATION,
            metadataWithoutBitmap.getLong(MediaMetadataCompat.METADATA_KEY_DURATION));
    builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt);
    return builder.build();
}
 
開發者ID:googlecodelabs,項目名稱:musicplayer-devices,代碼行數:24,代碼來源:MusicLibrary.java

示例6: createMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
private MediaMetadataCompat createMetadata() {
    MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE,
                mMediaNotificationInfo.metadata.getTitle());
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE,
                mMediaNotificationInfo.origin);
    } else {
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE,
                mMediaNotificationInfo.metadata.getTitle());
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST,
                mMediaNotificationInfo.origin);
    }
    if (!TextUtils.isEmpty(mMediaNotificationInfo.metadata.getArtist())) {
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST,
                mMediaNotificationInfo.metadata.getArtist());
    }
    if (!TextUtils.isEmpty(mMediaNotificationInfo.metadata.getAlbum())) {
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM,
                mMediaNotificationInfo.metadata.getAlbum());
    }

    return metadataBuilder.build();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:26,代碼來源:MediaNotificationManager.java

示例7: getMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
public static MediaMetadataCompat getMetadata(Context context, String mediaId) {
    MediaMetadataCompat metadataWithoutBitmap = music.get(mediaId);
    Bitmap albumArt = getAlbumBitmap(context, mediaId);

    // Since MediaMetadataCompat is immutable, we need to create a copy to set the album art.
    // We don't set it initially on all items so that they don't take unnecessary memory.
    MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
    for (String key :
            new String[]{
                    MediaMetadataCompat.METADATA_KEY_MEDIA_ID,
                    MediaMetadataCompat.METADATA_KEY_ALBUM,
                    MediaMetadataCompat.METADATA_KEY_ARTIST,
                    MediaMetadataCompat.METADATA_KEY_GENRE,
                    MediaMetadataCompat.METADATA_KEY_TITLE
            }) {
        builder.putString(key, metadataWithoutBitmap.getString(key));
    }
    builder.putLong(
            MediaMetadataCompat.METADATA_KEY_DURATION,
            metadataWithoutBitmap.getLong(MediaMetadataCompat.METADATA_KEY_DURATION));
    builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt);
    return builder.build();
}
 
開發者ID:nazmulidris,項目名稱:mediasession-mediaplayer,代碼行數:24,代碼來源:MusicLibrary.java

示例8: getMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
public static MediaMetadataCompat getMetadata(String mediaId) {
    MediaMetadataCompat metadataWithoutBitmap = music.get(mediaId);
    Bitmap albumArt = getAlbumBitmap(mediaId);

    // Since MediaMetadataCompat is immutable, we need to create a copy to set the album art.
    // We don't set it initially on all items so that they don't take unnecessary memory.
    MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
    for (String key :
            new String[]{
                    MediaMetadataCompat.METADATA_KEY_MEDIA_ID,
                    MediaMetadataCompat.METADATA_KEY_ALBUM,
                    MediaMetadataCompat.METADATA_KEY_ARTIST,
                    MediaMetadataCompat.METADATA_KEY_GENRE,
                    MediaMetadataCompat.METADATA_KEY_TITLE
            }) {
        builder.putString(key, metadataWithoutBitmap.getString(key));
    }
    builder.putLong(
            MediaMetadataCompat.METADATA_KEY_DURATION,
            metadataWithoutBitmap.getLong(MediaMetadataCompat.METADATA_KEY_DURATION));
    builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt);
    return builder.build();
}
 
開發者ID:fendoudebb,項目名稱:PlayAndroid,代碼行數:24,代碼來源:LocalMusicLibrary.java

示例9: updateMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
private void updateMetadata(final Video video) {
        final MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder();

        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, video.id + "");
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, video.title);
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, video.studio);
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION,
                video.description);

        /*
        long duration = Utils.getDuration(video.videoUrl);
        metadataBuilder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration);
*/
        long duration = getDuration();
        metadataBuilder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration);

        // And at minimum the title and artist for legacy support
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, video.title);
        metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, video.studio);

        Resources res = getResources();
        int cardWidth = res.getDimensionPixelSize(R.dimen.playback_overlay_width);
        int cardHeight = res.getDimensionPixelSize(R.dimen.playback_overlay_height);

        Glide.with(this)
                .load(Uri.parse(video.cardImageUrl))
                .asBitmap()
                .centerCrop()
                .into(new SimpleTarget<Bitmap>(cardWidth, cardHeight) {
                    @Override
                    public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                        metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, bitmap);
                        mSession.setMetadata(metadataBuilder.build());
                    }
                });
    }
 
開發者ID:nejtv,項目名稱:androidtv-sample,代碼行數:37,代碼來源:PlaybackOverlayFragment.java

示例10: updateMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
private void updateMetadata(final Clip clip) {
    final MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder();

    metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE, clip.getTitle());
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE,
            clip.getDescription());
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI,
            clip.getCardImageUrl());

    // And at minimum the title and artist for legacy support
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE, clip.getTitle());
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_ARTIST, clip.getDescription());

    Glide.with(this)
            .asBitmap()
            .load(Uri.parse(clip.getCardImageUrl()))
            .into(new SimpleTarget<Bitmap>(500, 500) {
                @Override
                public void onResourceReady(Bitmap bitmap, Transition transition) {
                    metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
                    mSession.setMetadata(metadataBuilder.build());
                }

                @Override
                public void onLoadFailed(Drawable errorDrawable) {
                    Log.e(TAG, "onLoadFailed: " + errorDrawable);
                    mSession.setMetadata(metadataBuilder.build());
                }
            });
}
 
開發者ID:googlesamples,項目名稱:leanback-homescreen-channels,代碼行數:31,代碼來源:VideoFragment.java

示例11: updateMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
private void updateMetadata(final Video video) {
    final MediaMetadataCompat.Builder metadataBuilder = new MediaMetadataCompat.Builder();

    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, video.id + "");
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, video.title);
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, video.studio);
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION,
            video.description);

    long duration = Utils.getDuration(video.videoUrl);
    metadataBuilder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration);

    // And at minimum the title and artist for legacy support
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, video.title);
    metadataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, video.studio);

    Resources res = getResources();
    int cardWidth = res.getDimensionPixelSize(R.dimen.playback_overlay_width);
    int cardHeight = res.getDimensionPixelSize(R.dimen.playback_overlay_height);

    Glide.with(this)
            .load(Uri.parse(video.cardImageUrl))
            .asBitmap()
            .centerCrop()
            .into(new SimpleTarget<Bitmap>(cardWidth, cardHeight) {
                @Override
                public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                    metadataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, bitmap);
                    mSession.setMetadata(metadataBuilder.build());
                }
            });
}
 
開發者ID:ad-on-is,項目名稱:chilly,代碼行數:33,代碼來源:PlaybackOverlayFragment.java

示例12: mapToMetadata

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的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

示例13: updateMediaSessionMetaData

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
private void updateMediaSessionMetaData() {
    final Song song = getCurrentSong();

    if (song.id == -1) {
        mediaSession.setMetadata(null);
        return;
    }

    final MediaMetadataCompat.Builder metaData = new MediaMetadataCompat.Builder()
            .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, song.artistName)
            .putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, song.artistName)
            .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.albumName)
            .putString(MediaMetadataCompat.METADATA_KEY_TITLE, song.title)
            .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.duration)
            .putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, getPosition() + 1)
            .putLong(MediaMetadataCompat.METADATA_KEY_YEAR, song.year)
            .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        metaData.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
    }

    if (PreferenceUtil.getInstance(this).albumArtOnLockscreen()) {
        final Point screenSize = Util.getScreenSize(MusicService.this);
        final BitmapRequestBuilder<?, Bitmap> request = SongGlideRequest.Builder.from(Glide.with(MusicService.this), song)
                .checkIgnoreMediaStore(MusicService.this)
                .asBitmap().build();
        if (PreferenceUtil.getInstance(this).blurredAlbumArt()) {
            request.transform(new BlurTransformation.Builder(MusicService.this).build());
        }
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                request.into(new SimpleTarget<Bitmap>(screenSize.x, screenSize.y) {
                    @Override
                    public void onLoadFailed(Exception e, Drawable errorDrawable) {
                        super.onLoadFailed(e, errorDrawable);
                        mediaSession.setMetadata(metaData.build());
                    }

                    @Override
                    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                        metaData.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, copy(resource));
                        mediaSession.setMetadata(metaData.build());
                    }
                });
            }
        });
    } else {
        mediaSession.setMetadata(metaData.build());
    }
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:53,代碼來源:MusicService.java

示例14: playFromUri

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
public void playFromUri(Uri uri, Bundle bundle) {
    mPlayOnFocusGain = true;
    tryToGetAudioFocus();
    registerAudioNoisyReceiver();

    mState = PlaybackStateCompat.STATE_STOPPED;
    relaxResources(true);

    try {
        createMediaPlayerIfNeeded();

        mState = PlaybackStateCompat.STATE_BUFFERING;
        mCurrentPosition = 0;

        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.setDataSource(uri.toString());

        // Starts preparing the media player in the background. When
        // it's done, it will call our OnPreparedListener (that is,
        // the onPrepared() method on this class, since we set the
        // listener to 'this'). Until the media player is prepared,
        // we *cannot* call start() on it!
        mMediaPlayer.prepareAsync();

        // If we are streaming from the internet, we want to hold a
        // Wifi lock, which prevents the Wifi radio from going to
        // sleep while the song is playing.
        mWifiLock.acquire();

        if (mCallback != null) {
            mCallback.onPlaybackStateChanged(mState);

            MediaMetadataCompat.Builder metaBuilder = new MediaMetadataCompat.Builder();
            metaBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, bundle.getString(MediaMetadataCompat.METADATA_KEY_ARTIST));
            metaBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, bundle.getString(MediaMetadataCompat.METADATA_KEY_TITLE));
            metaBuilder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI, bundle.getString(MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI));
            mCallback.onMediaMetadataChanged(metaBuilder.build());
        }

    } catch (IOException ex) {
        Log.e(TAG, ex +  "Exception playing song");
        if (mCallback != null) {
            mCallback.onError(ex.getMessage());
        }
    }
}
 
開發者ID:AllThatSeries,項目名稱:react-native-streaming-audio-player,代碼行數:47,代碼來源:Playback.java

示例15: setBitmapForLockScreen

import android.support.v4.media.MediaMetadataCompat; //導入方法依賴的package包/類
private void setBitmapForLockScreen(MediaInfo video) {
    if (video == null || mMediaSessionCompat == null) {
        return;
    }
    Uri imgUrl = null;
    Bitmap bm = null;
    List<WebImage> images = video.getMetadata().getImages();
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
        if (images.size() > 1) {
            imgUrl = images.get(1).getUrl();
        } else if (images.size() == 1) {
            imgUrl = images.get(0).getUrl();
        } else if (mContext != null) {
            // we don't have a url for image so get a placeholder image from resources
            bm = BitmapFactory.decodeResource(mContext.getResources(),
                    R.drawable.album_art_placeholder_large);
        }
    } else if (!images.isEmpty()) {
        imgUrl = images.get(0).getUrl();
    } else {
        // we don't have a url for image so get a placeholder image from resources
        bm = BitmapFactory.decodeResource(mContext.getResources(),
                R.drawable.album_art_placeholder);
    }
    if (bm != null) {
        MediaMetadataCompat currentMetadata = mMediaSessionCompat.getController().getMetadata();
        MediaMetadataCompat.Builder newBuilder = currentMetadata == null
                ? new MediaMetadataCompat.Builder()
                : new MediaMetadataCompat.Builder(currentMetadata);
        mMediaSessionCompat.setMetadata(newBuilder
                .putBitmap(MediaMetadataCompat.METADATA_KEY_ART, bm)
                .build());
    } else {
        if (mLockScreenFetchTask != null) {
            mLockScreenFetchTask.cancel(true);
        }
        Point screenSize = Utils.getDisplaySize(mContext);
        mLockScreenFetchTask = new FetchBitmapTask(screenSize.x, screenSize.y, false) {
            @Override
            protected void onPostExecute(Bitmap bitmap) {
                if (bitmap != null && mMediaSessionCompat != null) {
                    MediaMetadataCompat currentMetadata = mMediaSessionCompat.getController()
                            .getMetadata();
                    MediaMetadataCompat.Builder newBuilder = currentMetadata == null
                            ? new MediaMetadataCompat.Builder()
                            : new MediaMetadataCompat.Builder(currentMetadata);
                    mMediaSessionCompat.setMetadata(newBuilder
                            .putBitmap(MediaMetadataCompat.METADATA_KEY_ART, bitmap)
                            .build());
                }
                mLockScreenFetchTask = null;
            }
        };
        mLockScreenFetchTask.execute(imgUrl);
    }
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:57,代碼來源:VideoCastManager.java


注:本文中的android.support.v4.media.MediaMetadataCompat.Builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。