Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

belongs to Maven artifact androidx.media2:media2:1.0.0-alpha03

MediaMetadata2.Builder

public static final class MediaMetadata2.Builder
extends Object

java.lang.Object
   ↳ androidx.media2.MediaMetadata2.Builder


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

Summary

Public constructors

MediaMetadata2.Builder()

Create an empty Builder.

MediaMetadata2.Builder(MediaMetadata2 source)

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

Public methods

MediaMetadata2 build()

Creates a MediaMetadata2 instance with the specified fields.

MediaMetadata2.Builder putBitmap(String key, Bitmap value)

Put a Bitmap into the metadata.

MediaMetadata2.Builder putFloat(String key, float value)

Put a float value into the metadata.

MediaMetadata2.Builder putLong(String key, long value)

Put a long value into the metadata.

MediaMetadata2.Builder putRating(String key, Rating2 value)

Put a Rating2 into the metadata.

MediaMetadata2.Builder putString(String key, String value)

Put a String value into the metadata.

MediaMetadata2.Builder putText(String key, CharSequence value)

Put a CharSequence value into the metadata.

MediaMetadata2.Builder setExtras(Bundle extras)

Set a bundle of extras.

Inherited methods

Public constructors

MediaMetadata2.Builder

public MediaMetadata2.Builder ()

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

MediaMetadata2.Builder

public MediaMetadata2.Builder (MediaMetadata2 source)

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.

Public methods

build

public MediaMetadata2 build ()

Creates a MediaMetadata2 instance with the specified fields.

Returns
MediaMetadata2 The new MediaMetadata2x instance

putBitmap

public MediaMetadata2.Builder putBitmap (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 by the system when MediaSession.setMetadata(MediaMetadata) is called. To pass full resolution images Uris should be used with putString(String, String).

Parameters
key String: The key for referencing this value

value Bitmap: The Bitmap to store

Returns
MediaMetadata2.Builder The Builder to allow chaining

putFloat

public MediaMetadata2.Builder putFloat (String key, 
                float value)

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

Parameters
key String: The key for referencing this value

value float: The float value to store

Returns
MediaMetadata2.Builder The Builder to allow chaining

putLong

public MediaMetadata2.Builder putLong (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 String: The key for referencing this value

value long: The String value to store

Returns
MediaMetadata2.Builder The Builder to allow chaining

putRating

public MediaMetadata2.Builder putRating (String key, 
                Rating2 value)

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 Rating2: The String value to store

Returns
MediaMetadata2.Builder The Builder to allow chaining

setExtras

public MediaMetadata2.Builder setExtras (Bundle extras)

Set a bundle of extras.

Parameters
extras Bundle: The extras to include with this description or null.

Returns
MediaMetadata2.Builder The Builder to allow chaining