MetadataRetriever


@UnstableApi
public final class MetadataRetriever


Retrieves the static metadata of MediaItems.

Summary

Constants

static final int

The default number of maximum parallel retrievals.

Public methods

static ListenableFuture<TrackGroupArray>
retrieveMetadata(Context context, MediaItem mediaItem)

Retrieves the TrackGroupArray corresponding to a MediaItem.

static ListenableFuture<TrackGroupArray>
retrieveMetadata(
    MediaSource.Factory mediaSourceFactory,
    MediaItem mediaItem
)

Retrieves the TrackGroupArray corresponding to a MediaItem.

static void
setMaximumParallelRetrievals(int maximumParallelRetrievals)

Sets the maximum number of metadata retrievals run in parallel.

Constants

DEFAULT_MAXIMUM_PARALLEL_RETRIEVALS

public static final int DEFAULT_MAXIMUM_PARALLEL_RETRIEVALS = 5

The default number of maximum parallel retrievals.

Public methods

retrieveMetadata

public static ListenableFuture<TrackGroupArrayretrieveMetadata(Context context, MediaItem mediaItem)

Retrieves the TrackGroupArray corresponding to a MediaItem.

This is equivalent to using retrieveMetadata with a DefaultMediaSourceFactory and a DefaultExtractorsFactory with FLAG_READ_MOTION_PHOTO_METADATA and FLAG_READ_SEF_DATA set.

Parameters
Context context

The Context.

MediaItem mediaItem

The MediaItem whose metadata should be retrieved.

retrieveMetadata

public static ListenableFuture<TrackGroupArrayretrieveMetadata(
    MediaSource.Factory mediaSourceFactory,
    MediaItem mediaItem
)

Retrieves the TrackGroupArray corresponding to a MediaItem.

This method is thread-safe.

Parameters
MediaSource.Factory mediaSourceFactory

mediaSourceFactory The MediaSource.Factory to use to read the data.

MediaItem mediaItem

The MediaItem whose metadata should be retrieved.

setMaximumParallelRetrievals

public static void setMaximumParallelRetrievals(int maximumParallelRetrievals)

Sets the maximum number of metadata retrievals run in parallel.

The default is DEFAULT_MAXIMUM_PARALLEL_RETRIEVALS.

Parameters
int maximumParallelRetrievals

The maximum number of parallel retrievals.