DefaultContentMetadata


@UnstableApi
public final class DefaultContentMetadata implements ContentMetadata


Default implementation of ContentMetadata. Values are stored as byte arrays.

Summary

Constants

static final DefaultContentMetadata

An empty DefaultContentMetadata.

Public constructors

DefaultContentMetadata(Map<String, byte[]> metadata)

Public methods

final boolean

Returns whether the metadata is available.

DefaultContentMetadata

Returns a copy DefaultContentMetadata with mutations applied.

Set<Map.Entry<String, byte[]>>

Returns the set of metadata entries in their raw byte array form.

boolean
final @Nullable byte[]
get(String key, @Nullable byte[] defaultValue)

Returns a metadata value.

final long
get(String key, long defaultValue)

Returns a metadata value.

final @Nullable String
get(String key, @Nullable String defaultValue)

Returns a metadata value.

int

Inherited Constants

From androidx.media3.datasource.cache.ContentMetadata
static final String
KEY_CONTENT_LENGTH = "exo_len"

Key for content length in bytes (type: long).

static final String
KEY_CUSTOM_PREFIX = "custom_"

Prefix for custom metadata keys.

static final String
KEY_REDIRECTED_URI = "exo_redir"

Key for redirected uri (type: String).

Inherited methods

From androidx.media3.datasource.cache.ContentMetadata
static long

Returns the value stored under KEY_CONTENT_LENGTH, or LENGTH_UNSET if not set.

static @Nullable Uri

Returns the value stored under KEY_REDIRECTED_URI as a Uri, or {code null} if not set.

Constants

EMPTY

public static final DefaultContentMetadata EMPTY

An empty DefaultContentMetadata.

Public constructors

DefaultContentMetadata

public DefaultContentMetadata()

DefaultContentMetadata

public DefaultContentMetadata(Map<String, byte[]> metadata)
Parameters
Map<String, byte[]> metadata

The metadata entries in their raw byte array form.

Public methods

contains

public final boolean contains(String key)

Returns whether the metadata is available.

copyWithMutationsApplied

public DefaultContentMetadata copyWithMutationsApplied(ContentMetadataMutations mutations)

Returns a copy DefaultContentMetadata with mutations applied. If mutations don't change anything, returns this instance.

entrySet

public Set<Map.Entry<String, byte[]>> entrySet()

Returns the set of metadata entries in their raw byte array form.

equals

public boolean equals(@Nullable Object o)

get

public final @Nullable byte[] get(String key, @Nullable byte[] defaultValue)

Returns a metadata value.

Parameters
String key

Key of the metadata to be returned.

@Nullable byte[] defaultValue

Value to return if the metadata doesn't exist.

Returns
@Nullable byte[]

The metadata value.

get

public final long get(String key, long defaultValue)

Returns a metadata value.

Parameters
String key

Key of the metadata to be returned.

long defaultValue

Value to return if the metadata doesn't exist.

Returns
long

The metadata value.

get

public final @Nullable String get(String key, @Nullable String defaultValue)

Returns a metadata value.

Parameters
String key

Key of the metadata to be returned.

@Nullable String defaultValue

Value to return if the metadata doesn't exist.

Returns
@Nullable String

The metadata value.

hashCode

public int hashCode()