FrameworkStyle

MuteButton

A button component for muting and unmuting audio playback

Anatomy

<MuteButton />

Examples

Basic Usage

import { createPlayer, features, MuteButton, Video } from '@videojs/react';

import './BasicUsage.css';

const Player = createPlayer({ features: [...features.video] });

export default function BasicUsage() {
  return (
    <Player.Provider>
      <Player.Container className="mute-button-basic">
        <Video
          src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
          autoPlay
          muted
          playsInline
          loop
        />
        <MuteButton
          className="mute-button-basic__button"
          render={(props, state) => <button {...props}>{state.muted ? 'Unmute' : 'Mute'}</button>}
        />
      </Player.Container>
    </Player.Provider>
  );
}

API Reference

Props

Prop Type Default
disabled boolean false
label string | function ''

State

State is accessible via the render, className, and style props.

Property Type
volumeLevel 'off' | 'low' | 'medium' | 'high'
muted boolean

Data attributes

Attribute Description
data-muted Present when the media is muted.
data-volume-level Indicates the volume level.
VideoJS