mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
don't add 16x on every render
This commit is contained in:
parent
7c8142174e
commit
d2c3cdcf04
@ -6,24 +6,25 @@ import 'videojs-seek-buttons';
|
|||||||
import 'video.js/dist/video-js.css';
|
import 'video.js/dist/video-js.css';
|
||||||
import 'videojs-seek-buttons/dist/videojs-seek-buttons.css';
|
import 'videojs-seek-buttons/dist/videojs-seek-buttons.css';
|
||||||
|
|
||||||
|
export default function VideoPlayer({ children, options, seekOptions = {}, onReady = () => {}, onDispose = () => {} }) {
|
||||||
|
const playerRef = useRef();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
controls: true,
|
controls: true,
|
||||||
playbackRates: [0.5, 1, 2, 4, 8],
|
playbackRates: [0.5, 1, 2, 4, 8],
|
||||||
fluid: true,
|
fluid: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultSeekOptions = {
|
const defaultSeekOptions = {
|
||||||
forward: 30,
|
forward: 30,
|
||||||
back: 10,
|
back: 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function VideoPlayer({ children, options, seekOptions = {}, onReady = () => {}, onDispose = () => {} }) {
|
|
||||||
const playerRef = useRef();
|
|
||||||
|
|
||||||
if (!videojs.browser.IS_FIREFOX) {
|
if (!videojs.browser.IS_FIREFOX) {
|
||||||
defaultOptions.playbackRates.push(16);
|
defaultOptions.playbackRates.push(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const player = videojs(playerRef.current, { ...defaultOptions, ...options }, () => {
|
const player = videojs(playerRef.current, { ...defaultOptions, ...options }, () => {
|
||||||
onReady(player);
|
onReady(player);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user