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

## Import

```tsx
import { timeFeature } from '@videojs/react';
```

The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://videojs.org/docs/framework/react/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 [`usePlayer`](https://videojs.org/docs/framework/react/reference/api/use-player) to subscribe to time state. Returns `undefined` if the time feature is not configured.

**TimeDisplay.tsx**

```tsx
import { selectTime, usePlayer } from '@videojs/react';

function TimeDisplay() {
  const time = usePlayer(selectTime);
  if (!time) return null;

  return (
    <span>
      {Math.floor(time.currentTime)} / {Math.floor(time.duration)}
    </span>
  );
}
```

---

React documentation: https://videojs.org/docs/framework/react/llms.txt
All documentation: https://videojs.org/llms.txt
