selectSource
Select the source state slice from the player store
Pass selectSource to usePlayer to subscribe to source state. Returns undefined if the source feature is not configured.
Pass selectSource to PlayerController to subscribe to source state. Returns undefined if the source feature is not configured.
The returned state includes the current src and type.
import { usePlayer } from '@videojs/react';
import { selectSource } from '@videojs/core/dom';
function SourceInfo() {
const source = usePlayer(selectSource);
if (!source) return null;
return <span>{source.src}</span>;
}import { createPlayer, MediaElement } from '@videojs/html';
import { videoFeatures } from '@videojs/html/video';
import { selectSource } from '@videojs/core/dom';
const { PlayerController, context } = createPlayer({ features: videoFeatures });
class SourceInfo extends MediaElement {
#source = new PlayerController(this, context, selectSource);
}API Reference
Parameters
| Parameter | Type | Default | |
|---|---|---|---|
state* | object | — |
Return Value
MediaSourceState | undefined