MetadataRetriever
@UnstableApi
class MetadataRetriever : AutoCloseable
Retrieves information from a MediaItem without playback.
This class is intended for extracting metadata from media formats supported by Media3 players (such as ExoPlayer) for playback. It is not designed as a general-purpose metadata extractor for non-playback formats, such as standalone images. To extract properties like height, width, and rotation from images, use androidx.exifinterface.media.ExifInterface.
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 |
|---|
|
Builder for |
Constants |
|
|---|---|
const Int |
The default number of maximum parallel retrievals. |
Public functions |
|
|---|---|
Unit |
close() |
ListenableFuture<Long!>! |
Asynchronously retrieves the duration for the |
ListenableFuture<Timeline!>! |
|
ListenableFuture<TrackGroupArray!>! |
Asynchronously retrieves the |
java-static Unit |
setMaximumParallelRetrievals(maximumParallelRetrievals: Int)Sets the maximum number of metadata retrievals run in parallel. |
Constants
DEFAULT_MAXIMUM_PARALLEL_RETRIEVALS
const val DEFAULT_MAXIMUM_PARALLEL_RETRIEVALS = 5: Int
The default number of maximum parallel retrievals.
Public functions
retrieveDurationUs
fun retrieveDurationUs(): ListenableFuture<Long!>!
Asynchronously retrieves the duration for the MediaItem.
| Returns | |
|---|---|
ListenableFuture<Long!>! |
A |
retrieveTimeline
fun retrieveTimeline(): ListenableFuture<Timeline!>!
Asynchronously retrieves the Timeline for the MediaItem.
| Returns | |
|---|---|
ListenableFuture<Timeline!>! |
A |
retrieveTrackGroups
fun retrieveTrackGroups(): ListenableFuture<TrackGroupArray!>!
Asynchronously retrieves the TrackGroupArray for the MediaItem.
| Returns | |
|---|---|
ListenableFuture<TrackGroupArray!>! |
A |
setMaximumParallelRetrievals
java-static fun setMaximumParallelRetrievals(maximumParallelRetrievals: Int): Unit
Sets the maximum number of metadata retrievals run in parallel.
The default is DEFAULT_MAXIMUM_PARALLEL_RETRIEVALS.
| Parameters | |
|---|---|
maximumParallelRetrievals: Int |
The maximum number of parallel retrievals. |