public final class

MediaMetadataCompat.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.session.legacy.MediaMetadataCompat.Builder

Overview

Use to build MediaMetadata objects. The system defined metadata keys must use the appropriate data type.

Summary

Constructors
publicBuilder()

Create an empty Builder.

publicBuilder(MediaMetadataCompat source)

Create a Builder using a MediaMetadataCompat instance to set the initial values.

publicBuilder(MediaMetadataCompat source, int maxBitmapSize)

Create a Builder using a MediaMetadataCompat instance to set initial values, but replace bitmaps with a scaled down copy if they are larger than maxBitmapSize.

Methods
public MediaMetadataCompatbuild()

Creates a MediaMetadataCompat instance with the specified fields.

public MediaMetadataCompat.BuilderputBitmap(java.lang.String key, Bitmap value)

Put a Bitmap into the metadata.

public MediaMetadataCompat.BuilderputLong(java.lang.String key, long value)

Put a long value into the metadata.

public MediaMetadataCompat.BuilderputRating(java.lang.String key, RatingCompat value)

Put a RatingCompat into the metadata.

public MediaMetadataCompat.BuilderputString(java.lang.String key, java.lang.String value)

Put a String value into the metadata.

public MediaMetadataCompat.BuilderputText(java.lang.String key, java.lang.CharSequence value)

Put a CharSequence value into the metadata.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Create an empty Builder. Any field that should be included in the MediaMetadataCompat must be added.

public Builder(MediaMetadataCompat source)

Create a Builder using a MediaMetadataCompat instance to set the initial values. All fields in the source metadata will be included in the new metadata. Fields can be overwritten by adding the same key.

Parameters:

source:

public Builder(MediaMetadataCompat source, int maxBitmapSize)

Create a Builder using a MediaMetadataCompat instance to set initial values, but replace bitmaps with a scaled down copy if they are larger than maxBitmapSize.

Parameters:

source: The original metadata to copy.
maxBitmapSize: The maximum height/width for bitmaps contained in the metadata.

Methods

public MediaMetadataCompat.Builder putText(java.lang.String key, java.lang.CharSequence value)

Put a CharSequence value into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Parameters:

key: The key for referencing this value
value: The CharSequence value to store

Returns:

The Builder to allow chaining

public MediaMetadataCompat.Builder putString(java.lang.String key, java.lang.String value)

Put a String value into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Parameters:

key: The key for referencing this value
value: The String value to store

Returns:

The Builder to allow chaining

public MediaMetadataCompat.Builder putLong(java.lang.String key, long value)

Put a long value into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Parameters:

key: The key for referencing this value
value: The String value to store

Returns:

The Builder to allow chaining

public MediaMetadataCompat.Builder putRating(java.lang.String key, RatingCompat value)

Put a RatingCompat into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Parameters:

key: The key for referencing this value
value: The String value to store

Returns:

The Builder to allow chaining

public MediaMetadataCompat.Builder putBitmap(java.lang.String key, Bitmap value)

Put a Bitmap into the metadata. Custom keys may be used, but if the METADATA_KEYs defined in this class are used they may only be one of the following:

Large bitmaps may be scaled down when MediaSessionCompat.setMetadata(MediaMetadataCompat) is called. To pass full resolution images should be used with MediaMetadataCompat.Builder.putString(String, String).

Parameters:

key: The key for referencing this value
value: The Bitmap to store

Returns:

The Builder to allow chaining

public MediaMetadataCompat build()

Creates a MediaMetadataCompat instance with the specified fields.

Returns:

The new MediaMetadata instance