FrameworkStyle

selectTime

Select the time state slice from the player store

Pass selectTime to usePlayer to subscribe to time state. Returns undefined if the time feature is not configured.

The returned state includes currentTime, duration, and the seek action method.

import { usePlayer } from '@videojs/react';
import { selectTime } from '@videojs/core/dom';

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

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

API Reference

Parameters

Parameter Type Default
state* object

Return Value

MediaTimeState | undefined

VideoJS