Example usage for android.media MediaMetadata2 toBundle

List of usage examples for android.media MediaMetadata2 toBundle

Introduction

In this page you can find the example usage for android.media MediaMetadata2 toBundle.

Prototype

public @NonNull Bundle toBundle() 

Source Link

Document

Gets the bundle backing the metadata object.

Usage

From source file:androidx.media.MediaController2.java

/**
 * Updates the playlist metadata//from   ww  w. j  a  v  a  2  s .com
 *
 * @param metadata metadata of the playlist
 */
public void updatePlaylistMetadata(@Nullable MediaMetadata2 metadata) {
    Bundle args = new Bundle();
    args.putBundle(ARGUMENT_PLAYLIST_METADATA, metadata == null ? null : metadata.toBundle());
    sendCommand(COMMAND_CODE_PLAYLIST_SET_LIST_METADATA, args);
}

From source file:androidx.media.MediaController2.java

/**
 * Sets the playlist./* w  w  w.ja v a 2 s. co  m*/
 * <p>
 * Even when the playlist is successfully set, use the playlist returned from
 * {@link #getPlaylist()} for playlist APIs such as {@link #skipToPlaylistItem(MediaItem2)}.
 * Otherwise the session in the remote process can't distinguish between media items.
 *
 * @param list playlist
 * @param metadata metadata of the playlist
 * @see #getPlaylist()
 * @see ControllerCallback#onPlaylistChanged
 */
public void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) {
    if (list == null) {
        throw new IllegalArgumentException("list shouldn't be null");
    }
    Bundle args = new Bundle();
    args.putParcelableArray(ARGUMENT_PLAYLIST, MediaUtils2.toMediaItem2ParcelableArray(list));
    args.putBundle(ARGUMENT_PLAYLIST_METADATA, metadata == null ? null : metadata.toBundle());
    sendCommand(COMMAND_CODE_PLAYLIST_SET_LIST, args);
}