Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/media/MediaParser.SeekMap#constants) \| [Methods](https://developer.android.com/reference/android/media/MediaParser.SeekMap#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/MediaParser.SeekMap#inhmethods)

# MediaParser.SeekMap

*** ** * ** ***


`
public
static
final

class
MediaParser.SeekMap
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.MediaParser.SeekMap |

<br />

*** ** * ** ***

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

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

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/media/MediaParser.SeekMap#UNKNOWN_DURATION` Returned by `https://developer.android.com/reference/android/media/MediaParser.SeekMap#getDurationMicros()` when the duration is unknown. |

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

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


## Constants

### UNKNOWN_DURATION

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

```
public static final int UNKNOWN_DURATION
```

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

<br />

Constant Value:

-2147483648
(0x80000000)


## Public methods

### getDurationMicros

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

```
public long getDurationMicros ()
```

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

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getSeekPoints

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

```
public Pair<MediaParser.SeekPoint, MediaParser.SeekPoint> getSeekPoints (long timeMicros)
```

Obtains [seek points](https://developer.android.com/reference/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/android/media/MediaParser.SeekPoint` twice.

<br />

| Parameters ||
|---|---|
| `timeMicros` | `long`: A seek time in microseconds. <br /> |

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

### getSeekPoints

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public Pair<MediaParser.SeekPoint, MediaParser.SeekPoint> getSeekPoints (long timeMicros, 
                int trackIndex)
```

Obtains [seek points](https://developer.android.com/reference/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/android/media/MediaParser.SeekMap#getSeekPoints(long)`, but allows specifying a `trackIndex`. The `trackIndex` is the same index passed to `https://developer.android.com/reference/android/media/MediaParser.OutputConsumer#onTrackDataFound(int,%20android.media.MediaParser.TrackData)`.

Use `https://developer.android.com/reference/android/media/MediaParser.SeekMap#trackHasSeekPoints(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/android/media/MediaParser.SeekMap#getSeekPoints(long)`.

<br />

| Parameters ||
|---|---|
| `timeMicros` | `long`: A seek time in microseconds. <br /> |
| `trackIndex` | `int`: The index of the track to use for finding seek points. <br /> |

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

### isSeekable

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

```
public boolean isSeekable ()
```

Returns whether seeking is supported.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### trackHasSeekPoints

Added in [version 37.2](https://developer.android.com/topic/libraries/support-library/revisions)

```
public boolean trackHasSeekPoints (int trackIndex)
```

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

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

This method can return `false` for all tracks even when `https://developer.android.com/reference/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/android/media/MediaParser.SeekMap#getSeekPoints(long,%20int)` for that track will fall back to using the container's seek
points.

<br />

| Parameters ||
|---|---|
| `trackIndex` | `int`: The index of the track. <br /> |

| Returns ||
|---|---|
| `boolean` | Whether seeking is supported for the track. <br /> |