Skip to content
FrameworkStyle

Volume

Volume level and mute state for the player store

Controls volume level and mute state. These capabilities have independent availability values because media can support mute without supporting volume-level changes.

Import

import { volumeFeature } from '@videojs/html';

The audioFeatures, liveAudioFeatures, liveVideoFeatures, and videoFeatures feature bundles include this feature.

API Reference

State

PropertyTypeDetails
volumenumber
mutedboolean
volumeAvailability'available' | 'unavailable' | 'unsupported'
mutedAvailability'available' | 'unavailable' | 'unsupported'

Actions

ActionTypeDetails
setVolume(volume: number) => number
toggleMuted() => boolean

Selector

Pass selectVolume to PlayerController to subscribe to volume state. Returns undefined if the volume feature is not configured.

Check volumeAvailability before showing a volume-level control, and check mutedAvailability before showing a mute control.

import { createPlayer, UIElement, selectVolume } from '@videojs/html';
import { videoFeatures } from '@videojs/html/video';

const { PlayerController } = createPlayer({ features: videoFeatures });

class VolumeSlider extends UIElement {
  readonly #volume = new PlayerController(this, selectVolume);
}