Example usage for android.media MediaItem2 toBundle

List of usage examples for android.media MediaItem2 toBundle

Introduction

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

Prototype

public Bundle toBundle() 

Source Link

Document

Return this object as a bundle to share between processes.

Usage

From source file:androidx.media.MediaController2.java

/**
 * Removes the media item at index in the playlist.
 *<p>/*from   w  w  w .  j ava 2  s  .co m*/
 * If the item is the currently playing item of the playlist, current playback
 * will be stopped and playback moves to next source in the list.
 *
 * @param item the media item you want to add
 */
public void removePlaylistItem(@NonNull MediaItem2 item) {
    Bundle args = new Bundle();
    args.putBundle(ARGUMENT_MEDIA_ITEM, item.toBundle());
    sendCommand(COMMAND_CODE_PLAYLIST_REMOVE_ITEM, args);
}

From source file:androidx.media.MediaController2.java

/**
 * Skips to the item in the playlist./* ww w  .  j a v  a 2s  .c om*/
 * <p>
 * This calls {@link MediaPlaylistAgent#skipToPlaylistItem(MediaItem2)}.
 *
 * @param item The item in the playlist you want to play
 */
public void skipToPlaylistItem(@NonNull MediaItem2 item) {
    Bundle args = new Bundle();
    args.putBundle(ARGUMENT_MEDIA_ITEM, item.toBundle());
    sendCommand(COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM, args);
}

From source file:androidx.media.MediaController2.java

/**
 * Adds the media item to the playlist at position index. Index equals or greater than
 * the current playlist size (e.g. {@link Integer#MAX_VALUE}) will add the item at the end of
 * the playlist./*from ww  w  .  j  av  a  2  s  . c om*/
 * <p>
 * This will not change the currently playing media item.
 * If index is less than or equal to the current index of the playlist,
 * the current index of the playlist will be incremented correspondingly.
 *
 * @param index the index you want to add
 * @param item the media item you want to add
 */
public void addPlaylistItem(int index, @NonNull MediaItem2 item) {
    Bundle args = new Bundle();
    args.putInt(ARGUMENT_PLAYLIST_INDEX, index);
    args.putBundle(ARGUMENT_MEDIA_ITEM, item.toBundle());
    sendCommand(COMMAND_CODE_PLAYLIST_ADD_ITEM, args);
}

From source file:androidx.media.MediaController2.java

/**
 * Replace the media item at index in the playlist. This can be also used to update metadata of
 * an item./*from   ww w .java  2 s .c  om*/
 *
 * @param index the index of the item to replace
 * @param item the new item
 */
public void replacePlaylistItem(int index, @NonNull MediaItem2 item) {
    Bundle args = new Bundle();
    args.putInt(ARGUMENT_PLAYLIST_INDEX, index);
    args.putBundle(ARGUMENT_MEDIA_ITEM, item.toBundle());
    sendCommand(COMMAND_CODE_PLAYLIST_REPLACE_ITEM, args);
}