Builder

class Builder
kotlin.Any
   ↳ androidx.media2.common.MediaMetadata.Builder

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

Summary

Public constructors

Create an empty Builder.

<init>(@NonNull source: MediaMetadata)

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

Public methods

MediaMetadata

Creates a MediaMetadata instance with the specified fields.

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

Put a Bitmap into the metadata.

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

Put a float value into the metadata.

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

Put a long value into the metadata.

MediaMetadata.Builder
putRating(@NonNull key: String, @Nullable value: Rating?)

Put a Rating into the metadata.

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

Put a String value into the metadata.

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

Put a CharSequence value into the metadata.

MediaMetadata.Builder
setExtras(@Nullable extras: Bundle?)

Set a bundle of extras.

Public constructors

<init>

Builder()

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

<init>

Builder(@NonNull source: MediaMetadata)

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

Public methods

build

@NonNull fun build(): MediaMetadata

Creates a MediaMetadata instance with the specified fields.

Return
MediaMetadata: The new MediaMetadatax instance

putBitmap

@NonNull fun putBitmap(@NonNull key: String, @Nullable value: Bitmap?): MediaMetadata.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 when it is passed to the other process. 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
MediaMetadata.Builder: The Builder to allow chaining

putFloat

@NonNull fun putFloat(@NonNull key: String, value: Float): MediaMetadata.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
MediaMetadata.Builder: The Builder to allow chaining

putLong

@NonNull fun putLong(@NonNull key: String, value: Long): MediaMetadata.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
MediaMetadata.Builder: The Builder to allow chaining

putRating

@NonNull fun putRating(@NonNull key: String, @Nullable value: Rating?): MediaMetadata.Builder

Put a Rating 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
MediaMetadata.Builder: The Builder to allow chaining

putString

@NonNull fun putString(@NonNull key: String, @Nullable value: String?): MediaMetadata.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
MediaMetadata.Builder: The Builder to allow chaining

putText

@NonNull fun putText(@NonNull key: String, @Nullable value: CharSequence?): MediaMetadata.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
MediaMetadata.Builder: The Builder to allow chaining

setExtras

@NonNull fun setExtras(@Nullable extras: Bundle?): MediaMetadata.Builder

Set a bundle of extras.

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