hack-y solution to losing player context

use a global window variable to store the reference to the current video.js instance.
This commit is contained in:
DispatchCommit 2021-01-23 12:35:43 -08:00 committed by Sean Yesmunt
parent 68ae2d571f
commit d8564cda5a

View file

@ -170,7 +170,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
type: sourceType,
},
],
autoplay: false,
autoplay: true,
poster: poster, // thumb looks bad in app, and if autoplay, flashing poster is annoying
plugins: {
eventTracking: true,
@ -414,6 +414,8 @@ export default React.memo<Props>(function VideoJs(props: Props) {
useEffect(() => {
// For some reason the video player is responsible for detecting content type this way
fetch(source, { method: 'HEAD' }).then(response => {
const player = window.player;
if (!player) {
console.log(`Our player was disposed, we should disregard the fetch result.`);
return;