chore(deps): update video.js to the 8.x release

This commit is contained in:
Gabe Kangas
2023-05-06 17:40:42 -07:00
parent ca6ceabfe5
commit be60d94045
4 changed files with 124 additions and 63 deletions

View File

@@ -1,12 +1,14 @@
import React, { FC } from 'react';
import videojs, { VideoJsPlayer, VideoJsPlayerOptions } from 'video.js';
import videojs from 'video.js';
import type VideoJsPlayer from 'video.js/dist/types/player';
import styles from './VideoJS.module.scss';
require('video.js/dist/video-js.css');
export type VideoJSProps = {
options: VideoJsPlayerOptions;
onReady: (player: videojs.Player, vjsInstance: typeof videojs) => void;
options: any;
onReady: (player: VideoJsPlayer, vjsInstance: typeof videojs) => void;
};
export const VideoJS: FC<VideoJSProps> = ({ options, onReady }) => {
@@ -29,15 +31,17 @@ export const VideoJS: FC<VideoJSProps> = ({ options, onReady }) => {
}
// Add a cachebuster param to playlist URLs.
videojs.Vhs.xhr.beforeRequest = o => {
if (o.uri.match('m3u8')) {
const cachebuster = Math.random().toString(16).substr(2, 8);
// eslint-disable-next-line no-param-reassign
o.uri = `${o.uri}?cachebust=${cachebuster}`;
}
if ((videojs.getPlayer(videoRef.current).tech() as any)?.vhs) {
(videojs.getPlayer(videoRef.current).tech() as any).vhs.xhr.beforeRequest = o => {
if (o.uri.match('m3u8')) {
const cachebuster = Math.random().toString(16).substr(2, 8);
// eslint-disable-next-line no-param-reassign
o.uri = `${o.uri}?cachebust=${cachebuster}`;
}
return o;
};
return o;
};
}
}, [options, videoRef]);
return (