FrameworkStyle

PlayButton

A button component for playing and pausing media playback

Anatomy

<PlayButton />

Examples

Basic Usage

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

import './BasicUsage.css';

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

export default function BasicUsage() {
  return (
    <Player.Provider>
      <Player.Container className="play-button-basic">
        <Video
          src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
          autoPlay
          muted
          playsInline
          loop
        />
        <PlayButton
          className="play-button-basic__button"
          render={(props, state) => <button {...props}>{state.paused ? 'Play' : 'Pause'}</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
paused boolean
ended boolean
started boolean

Data attributes

Attribute Description
data-paused Present when the media is paused.
data-ended Present when the media has ended.
data-started Present when playback has started.
VideoJS