MetadataRetriever


@UnstableApi
public final class MetadataRetriever implements AutoCloseable


Retrieves information from a MediaItem without playback.

An instance is created for a single MediaItem via a Builder. It provides methods to asynchronously retrieve metadata. The instance must be closed after use to release resources.

Summary

Nested types

public final class MetadataRetriever.Builder

Builder for MetadataRetriever instances.

Constants

static final int

The default number of maximum parallel retrievals.

Public methods

void
ListenableFuture<Long>

Asynchronously retrieves the duration for the MediaItem.

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

This method is deprecated.

Use Builder to create an instance and call retrieveTrackGroups instead.

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

This method is deprecated.

Use Builder to create an instance and call retrieveTrackGroups instead.

ListenableFuture<Timeline>

Asynchronously retrieves the Timeline for the MediaItem.

ListenableFuture<TrackGroupArray>

Asynchronously retrieves the TrackGroupArray for the 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

close

public void close()

retrieveDurationUs

public ListenableFuture<LongretrieveDurationUs()

Asynchronously retrieves the duration for the MediaItem.

Returns
ListenableFuture<Long>

A ListenableFuture that will be populated with the duration in microseconds, or TIME_UNSET if unknown.

retrieveMetadata

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

retrieveMetadata

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

retrieveTimeline

public ListenableFuture<TimelineretrieveTimeline()

Asynchronously retrieves the Timeline for the MediaItem.

Returns
ListenableFuture<Timeline>

A ListenableFuture that will be populated with the Timeline.

retrieveTrackGroups

public ListenableFuture<TrackGroupArrayretrieveTrackGroups()

Asynchronously retrieves the TrackGroupArray for the MediaItem.

Returns
ListenableFuture<TrackGroupArray>

A ListenableFuture that will be populated with the TrackGroupArray.

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.