# MetadataRetriever

Artifact: [androidx.media3:media3-inspector](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/inspector/MetadataRetriever.java+class:androidx.media3.inspector.MetadataRetriever)

*** ** * ** ***

<br />

```
@UnstableApi
class MetadataRetriever : AutoCloseable
```

<br />

*** ** * ** ***

Retrieves information from a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` without playback.

This class is intended for extracting metadata from media formats supported by Media3 players (such as `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/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 `https://developer.android.com/reference/kotlin/androidx/exifinterface/media/ExifInterface`.

An instance is created for a single `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` via a `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever.Builder`. It provides methods to asynchronously retrieve metadata. The instance must be `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever#close()` after use to release resources.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever.Builder` Builder for `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever` instances. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever#DEFAULT_MAXIMUM_PARALLEL_RETRIEVALS() = 5` The default number of maximum parallel retrievals. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever#close()()` |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever#retrieveDurationUs()()` Asynchronously retrieves the duration for the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever#retrieveTimeline()()` Asynchronously retrieves the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` for the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TrackGroupArray!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever#retrieveTrackGroups()()` Asynchronously retrieves the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TrackGroupArray` for the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever#setMaximumParallelRetrievals(int)(maximumParallelRetrievals: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` 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

### close

```
fun close(): Unit
```

### retrieveDurationUs

```
fun retrieveDurationUs(): ListenableFuture<Long!>!
```

Asynchronously retrieves the duration for the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html!>!` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` that will be populated with the duration in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown. |

### retrieveTimeline

```
fun retrieveTimeline(): ListenableFuture<Timeline!>!
```

Asynchronously retrieves the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` for the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!>!` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` that will be populated with the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`. |

### retrieveTrackGroups

```
fun retrieveTrackGroups(): ListenableFuture<TrackGroupArray!>!
```

Asynchronously retrieves the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TrackGroupArray` for the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TrackGroupArray!>!` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` that will be populated with the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TrackGroupArray`. |

### setMaximumParallelRetrievals

```
java-static fun setMaximumParallelRetrievals(maximumParallelRetrievals: Int): Unit
```

Sets the maximum number of metadata retrievals run in parallel.

The default is `https://developer.android.com/reference/kotlin/androidx/media3/inspector/MetadataRetriever#DEFAULT_MAXIMUM_PARALLEL_RETRIEVALS()`.

| Parameters |
|---|---|
| `maximumParallelRetrievals: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum number of parallel retrievals. |