# TimestampIterator

# TimestampIterator

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/common/util/TimestampIterator "View this page in Java")

<br />

```
@UnstableApi
interface TimestampIterator
```

<br />

Known direct subclasses  
[ConstantRateTimestampIterator](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ConstantRateTimestampIterator)  

|-------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ConstantRateTimestampIterator](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ConstantRateTimestampIterator) | A[TimestampIterator](https://developer.android.com/reference/kotlin/androidx/media3/common/util/TimestampIterator)that generates monotonically increasing timestamps (in microseconds) distributed evenly over the given`durationUs`based on the given`frameRate`. |

*** ** * ** ***

A primitive long iterator used for generating sequences of timestamps.

## Summary

|                                                 ### Public functions                                                 |
|----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TimestampIterator](https://developer.android.com/reference/kotlin/androidx/media3/common/util/TimestampIterator)`!` | [copyOf](https://developer.android.com/reference/kotlin/androidx/media3/common/util/TimestampIterator#copyOf())`()` Returns fresh copy of the iterator.                                                                  |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                        | [getLastTimestampUs](https://developer.android.com/reference/kotlin/androidx/media3/common/util/TimestampIterator#getLastTimestampUs())`()` Returns the last (final) timestamp this iterator generates, in microseconds. |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                  | [hasNext](https://developer.android.com/reference/kotlin/androidx/media3/common/util/TimestampIterator#hasNext())`()` Returns whether there is another element.                                                          |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                        | [next](https://developer.android.com/reference/kotlin/androidx/media3/common/util/TimestampIterator#next())`()` Returns the next timestamp.                                                                              |

## Public functions

### copyOf

```
fun copyOf(): TimestampIterator!
```

Returns fresh copy of the iterator.  

### getLastTimestampUs

```
fun getLastTimestampUs(): Long
```

Returns the last (final) timestamp this iterator generates, in microseconds.

This method returns[TIME_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET())if the last timestamp is unknown, or when no timestamp will be generated.  

### hasNext

```
fun hasNext(): Boolean
```

Returns whether there is another element.  

### next

```
fun next(): Long
```

Returns the next timestamp.