PlaybackRateButton
A button that cycles through playback speed rates
Anatomy
<PlaybackRateButton /><media-playback-rate-button></media-playback-rate-button>Behavior
Cycles through playback rates on click. The default rate list is [1, 1.2, 1.5, 1.7, 2]. After the last rate, it wraps back to the first. If the current rate isn’t in the list (e.g., set programmatically), the button jumps to the next rate greater than the current one.
Styling
Display the current rate using the data-rate attribute:
media-playback-rate-button::after {
content: attr(data-rate) "\00D7";
} Use the render prop for rate display:
<PlaybackRateButton
render={(props, state) => <button {...props}>{state.rate}×</button>}
/>Accessibility
Renders a <button> with an automatic aria-label of "Playback rate {rate}" (e.g., "Playback rate 1.5"). Override with the label prop. Keyboard activation: Enter / Space.
Examples
Basic Usage
import { createPlayer, PlaybackRateButton } from '@videojs/react';
import { Video, videoFeatures } from '@videojs/react/video';
import './BasicUsage.css';
const Player = createPlayer({ features: videoFeatures });
export default function BasicUsage() {
return (
<Player.Provider>
<Player.Container className="react-playback-rate-button-basic">
<Video
src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
autoPlay
muted
playsInline
loop
/>
<PlaybackRateButton
className="react-playback-rate-button-basic__button"
render={(props, state) => <button {...props}>{Math.round(state.rate * 10) / 10}×</button>}
/>
</Player.Container>
</Player.Provider>
);
}
.react-playback-rate-button-basic {
position: relative;
}
.react-playback-rate-button-basic video {
width: 100%;
}
.react-playback-rate-button-basic__button {
padding-block: 8px;
position: absolute;
bottom: 10px;
left: 10px;
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
color: black;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 9999px;
padding-inline: 20px;
cursor: pointer;
}
<video-player class="html-playback-rate-button-basic">
<video
src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
autoplay
muted
playsinline
loop
></video>
<media-playback-rate-button class="html-playback-rate-button-basic__button">
</media-playback-rate-button>
</video-player>
.html-playback-rate-button-basic {
position: relative;
}
.html-playback-rate-button-basic video {
width: 100%;
}
.html-playback-rate-button-basic__button {
padding-block: 8px;
position: absolute;
bottom: 10px;
left: 10px;
background: rgba(255, 255, 255, 0.7);
backdrop-filter: blur(10px);
color: black;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 9999px;
padding-inline: 20px;
cursor: pointer;
}
.html-playback-rate-button-basic__button::after {
content: attr(data-rate) "\00D7";
}
import '@videojs/html/video/player';
import '@videojs/html/ui/playback-rate-button';
API Reference
Props
| Prop | Type | Default | |
|---|---|---|---|
disabled | boolean | false | |
| |||
label | string | function | '' | |
| |||
State
State is accessible via the
render, className, and style props.
State is reflected as data attributes for CSS styling.
| Property | Type | |
|---|---|---|
rate | number |
Data attributes
| Attribute | Type | |
|---|---|---|
data-rate | number | |
| ||