# ConstantRateTimestampIterator

# ConstantRateTimestampIterator

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/ConstantRateTimestampIterator.java+class:androidx.media3.common.util.ConstantRateTimestampIterator)

*** ** * ** ***

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

<br />

```
@UnstableApi
class ConstantRateTimestampIterator : TimestampIterator
```

<br />

*** ** * ** ***

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`.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                            ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ConstantRateTimestampIterator](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ConstantRateTimestampIterator#ConstantRateTimestampIterator(long,float))`(` ` durationUs: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` frameRate: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, fromInclusive = false) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) `)` Creates an instance that outputs timestamps from`0`.                                                                                                                                                                                                                             |
| [ConstantRateTimestampIterator](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ConstantRateTimestampIterator#ConstantRateTimestampIterator(long,long,float))`(` ` startPositionUs: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` endPositionUs: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` frameRate: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, fromInclusive = false) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) `)` Creates an instance that outputs timestamps from`startTimeUs`. |

|                                                             ### Public functions                                                             |
|----------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ConstantRateTimestampIterator](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ConstantRateTimestampIterator)`!` | [copyOf](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ConstantRateTimestampIterator#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/ConstantRateTimestampIterator#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/ConstantRateTimestampIterator#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/ConstantRateTimestampIterator#next())`()` Returns the next timestamp.                                                                              |

## Public constructors

### ConstantRateTimestampIterator

```
ConstantRateTimestampIterator(
    durationUs: @IntRange(from = 1) Long,
    frameRate: @FloatRange(from = 0, fromInclusive = false) Float
)
```

Creates an instance that outputs timestamps from`0`.  

|                                                                                                          Parameters                                                                                                          |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| `durationUs: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                             | The duration the timestamps should span over, in microseconds. |
| `frameRate: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, fromInclusive = false) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The frame rate in frames per second.                           |

### ConstantRateTimestampIterator

```
ConstantRateTimestampIterator(
    startPositionUs: @IntRange(from = 0) Long,
    endPositionUs: @IntRange(from = 1) Long,
    frameRate: @FloatRange(from = 0, fromInclusive = false) Float
)
```

Creates an instance that outputs timestamps from`startTimeUs`.  

|                                                                                                          Parameters                                                                                                          |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `startPositionUs: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                        | The start position in microseconds. The first timestamp generated will be equal to`startPositionUs`.                              |
| `endPositionUs: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                          | The end position at which the timestamps finish, in microseconds. The generated timestamps are less or equal to the end position. |
| `frameRate: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0, fromInclusive = false) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The frame rate in frames per second.                                                                                              |

## Public functions

### copyOf

```
fun copyOf(): ConstantRateTimestampIterator!
```

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.