update to 8.3.x (#6100)

This commit is contained in:
Blake Blackshear
2023-04-16 07:09:51 -05:00
committed by GitHub
parent 149d6694d6
commit f8f76fcb94
5 changed files with 199 additions and 141 deletions
+4 -11
View File
@@ -2,24 +2,21 @@ import { h } from 'preact';
import { useRef, useEffect } from 'preact/hooks';
import videojs from 'video.js';
import 'videojs-playlist';
import 'videojs-seek-buttons';
import 'video.js/dist/video-js.css';
import 'videojs-seek-buttons/dist/videojs-seek-buttons.css';
export default function VideoPlayer({ children, options, seekOptions = {}, onReady = () => {}, onDispose = () => {} }) {
export default function VideoPlayer({ children, options, seekOptions = {forward:30, backward: 10}, onReady = () => {}, onDispose = () => {} }) {
const playerRef = useRef();
useEffect(() => {
const defaultOptions = {
controls: true,
controlBar: {
skipButtons: seekOptions,
},
playbackRates: [0.5, 1, 2, 4, 8],
fluid: true,
};
const defaultSeekOptions = {
forward: 30,
back: 10,
};
if (!videojs.browser.IS_FIREFOX) {
defaultOptions.playbackRates.push(16);
@@ -28,10 +25,6 @@ export default function VideoPlayer({ children, options, seekOptions = {}, onRea
const player = videojs(playerRef.current, { ...defaultOptions, ...options }, () => {
onReady(player);
});
player.seekButtons({
...defaultSeekOptions,
...seekOptions,
});
// Allows player to continue on error
player.reloadSourceOnError();