Audio track
Audio track state and actions for the player store
Tracks available audio tracks and selects the enabled track.
Import
import { audioTrackFeature } from '@videojs/react';import { audioTrackFeature } from '@videojs/html';The videoFeatures feature bundle includes this feature.
API Reference
State
| Property | Type | Details |
|---|---|---|
audioTrackList | MediaAudioTrack[] | |
| ||
Actions
| Action | Type | Details |
|---|---|---|
selectAudioTrack | (value: string) => void | |
| ||
Selector
Pass selectAudioTrack to usePlayer to subscribe to audio track state. Returns undefined if the audio track feature is not configured.
Pass selectAudioTrack to PlayerController to subscribe to audio track state. Returns undefined if the audio track feature is not configured.
import { selectAudioTrack, usePlayer } from '@videojs/react';
function AudioTrackInfo() {
const audioTrack = usePlayer(selectAudioTrack);
if (!audioTrack) return null;
return <span>{audioTrack.audioTrackList.length} audio tracks</span>;
}import { createPlayer, UIElement, selectAudioTrack } from '@videojs/html';
import { videoFeatures } from '@videojs/html/video';
const { PlayerController } = createPlayer({ features: videoFeatures });
class AudioTrackInfo extends UIElement {
readonly #audioTrack = new PlayerController(this, selectAudioTrack);
}