Builder

class Builder
kotlin.Any
   ↳ androidx.media2.MediaMetadata2.Builder

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

Summary

Public constructors

Create an empty Builder.

<init>(@NonNull source: MediaMetadata2)

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

Public methods
MediaMetadata2.Builder
putLong(@NonNull key: String, value: Long)

Put a long value into the metadata.

MediaMetadata2.Builder
putFloat(@NonNull key: String, value: Float)

Put a float value into the metadata.

MediaMetadata2.Builder
putText(@NonNull key: String, @Nullable value: CharSequence?)

Put a CharSequence value into the metadata.

MediaMetadata2.Builder!
setExtras(@Nullable extras: Bundle?)

Set a bundle of extras.

MediaMetadata2.Builder
putBitmap(@NonNull key: String, @Nullable value: Bitmap?)

Put a Bitmap into the metadata.

MediaMetadata2.Builder
putRating(@NonNull key: String, @Nullable value: Rating2?)

Put a Rating2 into the metadata.

MediaMetadata2.Builder
putString(@NonNull key: String, @Nullable value: String?)

Put a String value into the metadata.

MediaMetadata2

Creates a MediaMetadata2 instance with the specified fields.

Public constructors

<init>

Builder()

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

<init>

Builder(@NonNull source: MediaMetadata2)

Create a Builder using a MediaMetadata2 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 MediaMetadata2:

Public methods

putLong

@NonNull fun putLong(@NonNull key: String, value: Long): MediaMetadata2.Builder

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 String: The key for referencing this value
value String: The String value to store
Return
MediaMetadata2.Builder: The Builder to allow chaining

putFloat

@NonNull fun putFloat(@NonNull key: String, value: Float): MediaMetadata2.Builder

Put a float value into the metadata. Custom keys may be used.

Parameters
key String: The key for referencing this value
value String: The float value to store
Return
MediaMetadata2.Builder: The Builder to allow chaining

putText

@NonNull fun putText(@NonNull key: String, @Nullable value: CharSequence?): MediaMetadata2.Builder

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 String: The key for referencing this value
value String: The CharSequence value to store
Return
MediaMetadata2.Builder: The Builder to allow chaining

setExtras

fun setExtras(@Nullable extras: Bundle?): MediaMetadata2.Builder!

Set a bundle of extras.

Parameters
extras Bundle?: The extras to include with this description or null.
Return
MediaMetadata2.Builder!: The Builder to allow chaining

putBitmap

@NonNull fun putBitmap(@NonNull key: String, @Nullable value: Bitmap?): MediaMetadata2.Builder

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 by the system when android.media.session.MediaSession#setMetadata is called. To pass full resolution images Uris should be used with putString.

Parameters
key String: The key for referencing this value
value String: The Bitmap to store
Return
MediaMetadata2.Builder: The Builder to allow chaining

putRating

@NonNull fun putRating(@NonNull key: String, @Nullable value: Rating2?): MediaMetadata2.Builder

Put a Rating2 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 String: The key for referencing this value
value String: The String value to store
Return
MediaMetadata2.Builder: The Builder to allow chaining

putString

@NonNull fun putString(@NonNull key: String, @Nullable value: String?): MediaMetadata2.Builder

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 String: The key for referencing this value
value String: The String value to store
Return
MediaMetadata2.Builder: The Builder to allow chaining

build

@NonNull fun build(): MediaMetadata2

Creates a MediaMetadata2 instance with the specified fields.

Return
MediaMetadata2: The new MediaMetadata2x instance