FrameworkStyle

selectSource

Select the source state slice from the player store

Import

import { selectSource } from '@videojs/core/dom';

Usage

Pass selectSource to usePlayer (React) or PlayerController (HTML) to subscribe to source state. Returns undefined if the source feature is not configured.

The returned state includes the current src and type.

import { createPlayer, features, MediaElement } from '@videojs/html';
import { selectSource } from '@videojs/core/dom';

const { PlayerController, context } = createPlayer({ features: features.video });

class SourceInfo extends MediaElement {
  #source = new PlayerController(this, context, selectSource);
}

API Reference

Parameters

Parameter Type Default
state* {}

Return Value

MediaSourceState | undefined

VideoJS