# 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](https://videojs.org/docs/framework/html/reference/api/feature-buffer) 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](https://videojs.org/docs/framework/html/reference/api/feature-live) or [stream type](https://videojs.org/docs/framework/html/reference/api/feature-stream-type) to check whether the source is live.

## Import

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

The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://videojs.org/docs/framework/html/guides/presets) 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`](https://videojs.org/docs/framework/html/reference/api/player-controller) 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);
}
```

---

HTML documentation: https://videojs.org/docs/framework/html/llms.txt
All documentation: https://videojs.org/llms.txt
