Audio track
Audio track state and actions for the player store
Tracks available audio tracks and selects the enabled track.
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, MediaElement, selectAudioTrack } from '@videojs/html';
import { videoFeatures } from '@videojs/html/video';
const { PlayerController, context } = createPlayer({ features: videoFeatures });
class AudioTrackInfo extends MediaElement {
readonly #audioTrack = new PlayerController(this, context, selectAudioTrack);
}