only react to source prop updates

This commit is contained in:
DispatchCommit 2021-01-23 12:28:31 -08:00 committed by Sean Yesmunt
parent 7c8383f2dc
commit 68ae2d571f

View file

@ -404,11 +404,13 @@ export default React.memo<Props>(function VideoJs(props: Props) {
if (player) { if (player) {
player.dispose(); player.dispose();
window.player = undefined; window.player = undefined;
console.log(`Disposed of video.js instance (unmounted)`);
} }
} }
}, []); }, []);
// Update video player settings and reload it when props change // Update video player and reload when source URL changes
useEffect(() => { useEffect(() => {
// For some reason the video player is responsible for detecting content type this way // For some reason the video player is responsible for detecting content type this way
fetch(source, { method: 'HEAD' }).then(response => { fetch(source, { method: 'HEAD' }).then(response => {
@ -443,9 +445,9 @@ export default React.memo<Props>(function VideoJs(props: Props) {
}); });
return () => { return () => {
console.log('Guess we could clean up something here if needed'); console.log('Cleanup after source update.');
}; }
}); }, [source]);
return ( return (
reload && ( reload && (