# Time

Playback position and duration state for the player store

Tracks playback position and duration. During live playback, the browser may report `Infinity` as the duration. The player reports the end of the last available [seekable range](./feature-buffer.md) instead, so the value stays finite and moves forward with the stream. This is the newest available time, not the length of the rewindable window; its first available time may be greater than zero. Use [live state](./feature-live.md) or [stream type](./feature-stream-type.md) to check whether the source is live.

## Import

```ts
import { timeFeature } from '@videojs/html';
```

The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](../../guides/presets.md) include this feature.

## API Reference

### State

| Property | Type | Description |
| --- | --- | --- |
| `currentTime` | `number` | Current playback position in seconds. |
| `duration` | `number` | Total duration in seconds (0 if unknown). |
| `seeking` | `boolean` | Whether a seek operation is in progress. |

### Actions

| Action | Type | Description |
| --- | --- | --- |
| `seek` | `(time: number) => Promise<number>` | Seek to a time in seconds. Returns the actual position after seek. |

### Selector

Pass `selectTime` to [`PlayerController`](./player-controller.md) to subscribe to time state. Returns `undefined` if the time feature is not configured.

**time-display.ts**

```ts
import { createPlayer, UIElement, selectTime } from '@videojs/html';
import { videoFeatures } from '@videojs/html/video';

const { PlayerController } = createPlayer({ features: videoFeatures });

class TimeDisplay extends UIElement {
  readonly #time = new PlayerController(this, selectTime);
}
```