Example usage for android.os Bundle putBundle

List of usage examples for android.os Bundle putBundle

Introduction

In this page you can find the example usage for android.os Bundle putBundle.

Prototype

public void putBundle(@Nullable String key, @Nullable Bundle value) 

Source Link

Document

Inserts a Bundle value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:androidx.media.MediaController2.java

/**
 * Removes the media item at index in the playlist.
 *<p>//from w  w w  . j a  va2s .c o 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.//from  w ww.  j av a 2 s  .  c  o  m
 * <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

/**
 * Selects the specified route./*www  .j  a v a 2 s .c  o m*/
 *
 * @param route The route to select.
 */
public void selectRoute(@NonNull Bundle route) {
    if (route == null) {
        throw new IllegalArgumentException("route shouldn't be null");
    }
    Bundle args = new Bundle();
    args.putBundle(ARGUMENT_ROUTE_BUNDLE, route);
    sendCommand(COMMAND_CODE_SESSION_SELECT_ROUTE, args);
}

From source file:androidx.media.MediaController2.java

/**
 * Send custom command to the session/*from   w  ww .j a va 2 s  .c o m*/
 *
 * @param command custom command
 * @param args optional argument
 * @param cb optional result receiver
 */
public void sendCustomCommand(@NonNull SessionCommand2 command, @Nullable Bundle args,
        @Nullable ResultReceiver cb) {
    synchronized (mLock) {
        if (!mConnected) {
            Log.w(TAG, "Session isn't active", new IllegalStateException());
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putBundle(ARGUMENT_CUSTOM_COMMAND, command.toBundle());
        bundle.putBundle(ARGUMENT_ARGUMENTS, args);
        sendCommand(CONTROLLER_COMMAND_BY_CUSTOM_COMMAND, bundle, cb);
    }
}

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  w  w  w  .j  av  a 2 s .  c o  m*/
 * <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  w w w .j  a va2s.  c  o  m
 *
 * @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);
}

From source file:androidx.media.MediaController2.java

/**
 * Request that the player start playback for a specific search query.
 *
 * @param query The search query. Should not be an empty string.
 * @param extras Optional extras that can include extra information about the query.
 *//*  www .  j av a  2 s  .  c o  m*/
public void playFromSearch(@NonNull String query, @Nullable Bundle extras) {
    synchronized (mLock) {
        if (!mConnected) {
            Log.w(TAG, "Session isn't active", new IllegalStateException());
            return;
        }
        Bundle args = new Bundle();
        args.putString(ARGUMENT_QUERY, query);
        args.putBundle(ARGUMENT_EXTRAS, extras);
        sendCommand(COMMAND_CODE_SESSION_PLAY_FROM_SEARCH, args);
    }
}

From source file:androidx.media.MediaController2.java

/**
 * Request that the player start playback for a specific {@link Uri}.
 *
 * @param uri The URI of the requested media.
 * @param extras Optional extras that can include extra information about the media item
 *               to be played.// w w w.  j  a  va 2 s  .  c  om
 */
public void playFromUri(@NonNull Uri uri, @Nullable Bundle extras) {
    synchronized (mLock) {
        if (!mConnected) {
            Log.w(TAG, "Session isn't active", new IllegalStateException());
            return;
        }
        Bundle args = new Bundle();
        args.putParcelable(ARGUMENT_URI, uri);
        args.putBundle(ARGUMENT_EXTRAS, extras);
        sendCommand(COMMAND_CODE_SESSION_PLAY_FROM_URI, args);
    }
}

From source file:androidx.media.MediaController2.java

/**
 * Request that the player prepare playback for a specific search query.
 * In other words, other sessions can continue to play during the preparation of this session.
 * This method can be used to speed up the start of the playback.
 * Once the preparation is done, the session will change its playback state to
 * {@link MediaPlayerBase#PLAYER_STATE_PAUSED}. Afterwards,
 * {@link #play} can be called to start playback. If the preparation is not needed,
 * {@link #playFromSearch} can be directly called without this method.
 *
 * @param query The search query. Should not be an empty string.
 * @param extras Optional extras that can include extra information about the query.
 *///from   w w  w.j  a  va  2  s .  c  o m
public void prepareFromSearch(@NonNull String query, @Nullable Bundle extras) {
    synchronized (mLock) {
        if (!mConnected) {
            Log.w(TAG, "Session isn't active", new IllegalStateException());
            return;
        }
        Bundle args = new Bundle();
        args.putString(ARGUMENT_QUERY, query);
        args.putBundle(ARGUMENT_EXTRAS, extras);
        sendCommand(COMMAND_CODE_SESSION_PREPARE_FROM_SEARCH, args);
    }
}

From source file:androidx.media.MediaController2.java

/**
 * Request that the player prepare playback for a specific {@link Uri}. In other words,
 * other sessions can continue to play during the preparation of this session. This method
 * can be used to speed up the start of the playback. Once the preparation is done, the
 * session will change its playback state to {@link MediaPlayerBase#PLAYER_STATE_PAUSED}.
 * Afterwards, {@link #play} can be called to start playback. If the preparation is not needed,
 * {@link #playFromUri} can be directly called without this method.
 *
 * @param uri The URI of the requested media.
 * @param extras Optional extras that can include extra information about the media item
 *               to be prepared.//w ww  . ja va2 s.  co  m
 */
public void prepareFromUri(@NonNull Uri uri, @Nullable Bundle extras) {
    synchronized (mLock) {
        if (!mConnected) {
            Log.w(TAG, "Session isn't active", new IllegalStateException());
            return;
        }
        Bundle args = new Bundle();
        args.putParcelable(ARGUMENT_URI, uri);
        args.putBundle(ARGUMENT_EXTRAS, extras);
        sendCommand(COMMAND_CODE_SESSION_PREPARE_FROM_URI, args);
    }
}