Example usage for android.media Rating2 toBundle

List of usage examples for android.media Rating2 toBundle

Introduction

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

Prototype

public Bundle toBundle() 

Source Link

Document

Return bundle for this object to share across the process.

Usage

From source file:androidx.media.MediaController2.java

/**
 * Rate the media. This will cause the rating to be set for the current user.
 * The rating style must follow the user rating style from the session.
 * You can get the rating style from the session through the
 * {@link MediaMetadata2#getRating(String)} with the key
 * {@link MediaMetadata2#METADATA_KEY_USER_RATING}.
 * <p>//  w w  w  .j  av  a2  s. c  om
 * If the user rating was {@code null}, the media item does not accept setting user rating.
 *
 * @param mediaId The id of the media
 * @param rating The rating to set
 */
public void setRating(@NonNull String mediaId, @NonNull Rating2 rating) {
    synchronized (mLock) {
        if (!mConnected) {
            Log.w(TAG, "Session isn't active", new IllegalStateException());
            return;
        }
        Bundle args = new Bundle();
        args.putString(ARGUMENT_MEDIA_ID, mediaId);
        args.putBundle(ARGUMENT_RATING, rating.toBundle());
        sendCommand(COMMAND_CODE_SESSION_SET_RATING, args);
    }
}