Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# SeekMap

*** ** * ** ***

```
class SeekMap
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.media.MediaParser.SeekMap](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#) |

Maps seek positions to `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint` in the stream.

A `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint` is a position in the stream from which a player may successfully start playing media samples.

## Summary

| Constants ||
|---|---|
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#UNKNOWN_DURATION:kotlin.Int` Returned by `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#getDurationMicros()` when the duration is unknown. |

| Public methods ||
|---|---|
| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#getDurationMicros()()` Returns the duration of the stream in microseconds or `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#UNKNOWN_DURATION:kotlin.Int` if the duration is unknown. |
| [Pair](https://developer.android.com/reference/kotlin/android/util/Pair.html#)\<[MediaParser.SeekPoint](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint)!, [MediaParser.SeekPoint](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint)!\> | `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#getSeekPoints(kotlin.Long)(timeMicros: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Obtains [seek points](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint) for the specified seek time in microseconds. |
| [Pair](https://developer.android.com/reference/kotlin/android/util/Pair.html#)\<[MediaParser.SeekPoint](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint)!, [MediaParser.SeekPoint](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint)!\> | `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#getSeekPoints(kotlin.Long,%20kotlin.Int)(timeMicros: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html, trackIndex: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Obtains [seek points](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint) for the specified seek time in microseconds, using cue points from a specific track. |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#isSeekable()()` Returns whether seeking is supported. |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#trackHasSeekPoints(kotlin.Int)(trackIndex: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Returns whether the given track has its own [seek points](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint). |

## Constants

### UNKNOWN_DURATION

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val UNKNOWN_DURATION: Int
```

Returned by `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#getDurationMicros()` when the duration is unknown.

    Value: -2147483648

## Public methods

### getDurationMicros

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun getDurationMicros(): Long
```

Returns the duration of the stream in microseconds or `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#UNKNOWN_DURATION:kotlin.Int` if the duration is unknown.

### getSeekPoints

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun getSeekPoints(timeMicros: Long): Pair<MediaParser.SeekPoint!, MediaParser.SeekPoint!>
```

Obtains [seek points](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint) for the specified seek time in microseconds.

`getSeekPoints(timeMicros).first` contains the latest seek point for samples with timestamp equal to or smaller than `timeMicros`.

`getSeekPoints(timeMicros).second` contains the earliest seek point for samples with timestamp equal to or greater than `timeMicros`. If a seek point exists for `timeMicros`, the returned pair will contain the same `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint` twice.

| Parameters ||
|---|---|
| `timeMicros` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): A seek time in microseconds. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/util/Pair.html#<https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint!, https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint!>` | The corresponding [seek points](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint). This value cannot be `null`. |

### getSeekPoints

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun getSeekPoints(
    timeMicros: Long, 
    trackIndex: Int
): Pair<MediaParser.SeekPoint!, MediaParser.SeekPoint!>
```

Obtains [seek points](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint) for the specified seek time in microseconds, using cue points from a specific track.

This method is similar to `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#getSeekPoints(kotlin.Long)`, but allows specifying a `trackIndex`. The `trackIndex` is the same index passed to `https://developer.android.com/reference/kotlin/android/media/MediaParser.OutputConsumer#onTrackDataFound(kotlin.Int,%20android.media.MediaParser.TrackData)`.

Use `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#trackHasSeekPoints(kotlin.Int)` to check if a track has its own seek points. If it returns `false` for the given `trackIndex`, this method will fall back to using the container's seek points, which is equivalent to calling `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#getSeekPoints(kotlin.Long)`.

| Parameters ||
|---|---|
| `timeMicros` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): A seek time in microseconds. |
| `trackIndex` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The index of the track to use for finding seek points. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/util/Pair.html#<https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint!, https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint!>` | The corresponding [seek points](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint). This value cannot be `null`. |

### isSeekable

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun isSeekable(): Boolean
```

Returns whether seeking is supported.

### trackHasSeekPoints

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun trackHasSeekPoints(trackIndex: Int): Boolean
```

Returns whether the given track has its own [seek points](https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekPoint).

The `trackIndex` is the same index passed to `https://developer.android.com/reference/kotlin/android/media/MediaParser.OutputConsumer#onTrackDataFound(kotlin.Int,%20android.media.MediaParser.TrackData)`.

This method can return `false` for all tracks even when `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#isSeekable()` returns `true`. In such cases, seeking is supported for the container, but not on a per-track basis. When this method returns `false` for a given track, calling `https://developer.android.com/reference/kotlin/android/media/MediaParser.SeekMap#getSeekPoints(kotlin.Long,%20kotlin.Int)` for that track will fall back to using the container's seek points.

| Parameters ||
|---|---|
| `trackIndex` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The index of the track. |

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | Whether seeking is supported for the track. |