Skip to content

Commit

Permalink
don't add 16x on every render
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear committed May 16, 2022
1 parent 7c81421 commit d2c3cdc
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions web/src/components/VideoPlayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ import 'videojs-seek-buttons';
import 'video.js/dist/video-js.css';
import 'videojs-seek-buttons/dist/videojs-seek-buttons.css';

const defaultOptions = {
controls: true,
playbackRates: [0.5, 1, 2, 4, 8],
fluid: true,
};
const defaultSeekOptions = {
forward: 30,
back: 10,
};

export default function VideoPlayer({ children, options, seekOptions = {}, onReady = () => {}, onDispose = () => {} }) {
const playerRef = useRef();

if (!videojs.browser.IS_FIREFOX) {
defaultOptions.playbackRates.push(16);
}


useEffect(() => {
const defaultOptions = {
controls: true,
playbackRates: [0.5, 1, 2, 4, 8],
fluid: true,
};

const defaultSeekOptions = {
forward: 30,
back: 10,
};

if (!videojs.browser.IS_FIREFOX) {
defaultOptions.playbackRates.push(16);
}

const player = videojs(playerRef.current, { ...defaultOptions, ...options }, () => {
onReady(player);
});
Expand Down

0 comments on commit d2c3cdc

Please sign in to comment.