diff --git a/web/package-lock.json b/web/package-lock.json index aaf208728..39a881299 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -11947,15 +11947,6 @@ "resolved": "https://registry.npmjs.org/videojs-font/-/videojs-font-3.2.0.tgz", "integrity": "sha512-g8vHMKK2/JGorSfqAZQUmYYNnXmfec4MLhwtEFS+mMs2IDY398GLysy6BH6K+aS1KMNu/xWZ8Sue/X/mdQPliA==" }, - "videojs-mobile-ui": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/videojs-mobile-ui/-/videojs-mobile-ui-0.5.3.tgz", - "integrity": "sha512-rY+JFLUq2edqoWB4CHVxPLYQEYhSNdGylGe44MEdfxzqYaEgkf/qyDlmmpdN9BFIQ6vJ7eaQBxgTOHha8UpOGA==", - "requires": { - "global": "^4.3.2", - "video.js": "^5.19.2 || ^6.6.0 || ^7.0.0" - } - }, "videojs-playlist": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/videojs-playlist/-/videojs-playlist-4.3.1.tgz", @@ -11966,9 +11957,9 @@ } }, "videojs-seek-buttons": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/videojs-seek-buttons/-/videojs-seek-buttons-2.0.0.tgz", - "integrity": "sha512-fSq2COvwTT5OwD5urc3E+ktQRwdjptXNaeuv1Tld2yfoV1ep9Am9gE/O07ADgHJVedFatVUXnifTh6wlUWSyTA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/videojs-seek-buttons/-/videojs-seek-buttons-2.0.1.tgz", + "integrity": "sha512-FIWIy0l1cy8zbJEcjBpL7m8t54219HNPRLfGcvs++CV3J7E6HbmF1bVwVMyh3Iev/Y95s0tnn0x5P6w/HTulfw==", "requires": { "global": "^4.4.0", "video.js": "^6 || ^7" diff --git a/web/package.json b/web/package.json index a75029431..052d98234 100644 --- a/web/package.json +++ b/web/package.json @@ -18,9 +18,8 @@ "preact-async-route": "^2.2.1", "preact-router": "^3.2.1", "video.js": "^7.11.8", - "videojs-mobile-ui": "^0.5.3", "videojs-playlist": "^4.3.1", - "videojs-seek-buttons": "^2.0.0" + "videojs-seek-buttons": "^2.0.1" }, "devDependencies": { "@babel/eslint-parser": "^7.12.13", diff --git a/web/snowpack.config.js b/web/snowpack.config.js index 085042a56..7258eaeba 100644 --- a/web/snowpack.config.js +++ b/web/snowpack.config.js @@ -4,7 +4,7 @@ module.exports = { src: { url: '/dist' }, }, plugins: ['@snowpack/plugin-postcss', '@prefresh/snowpack', 'snowpack-plugin-hash'], - routes: [{ match: 'routes', src: '.*', dest: '/index.html' }], + routes: [{ match: 'all', src: '(?!.*(.svg|.gif|.json|.jpg|.jpeg|.png|.js)).*', dest: '/index.html' }], optimize: { bundle: false, minify: true, diff --git a/web/src/components/VideoPlayer.jsx b/web/src/components/VideoPlayer.jsx index d4d6eb34b..fa99fe063 100644 --- a/web/src/components/VideoPlayer.jsx +++ b/web/src/components/VideoPlayer.jsx @@ -1,6 +1,6 @@ import { h, Component } from 'preact'; +import { useRef, useEffect } from 'preact/hooks'; import videojs from 'video.js'; -import 'videojs-mobile-ui'; import 'videojs-playlist'; import 'videojs-seek-buttons'; import 'video.js/dist/video-js.css'; @@ -11,49 +11,85 @@ const defaultOptions = { playbackRates: [0.5, 1, 2, 4, 8], fluid: true, }; +const defaultSeekOptions = { + forward: 30, + back: 10, +}; -export default class VideoPlayer extends Component { - componentDidMount() { - const { options, onReady = () => {} } = this.props; - const videoJsOptions = { - ...defaultOptions, - ...options, - }; - this.player = videojs(this.videoNode, videoJsOptions, function onPlayerReady() { - onReady(this); - }); - this.player.seekButtons({ - forward: 30, - back: 10, - }); - this.player.mobileUi({ - fullscreen: { - iOS: true, - }, - }); - } +export default function VideoPlayer({ children, options, seekOptions = {}, onReady = () => {}, onDispose = () => {} }) { + const playerRef = useRef(); - componentWillUnmount() { - const { onDispose = () => {} } = this.props; - if (this.player) { - this.player.dispose(); - onDispose(); + useEffect(() => { + const player = videojs(playerRef.current, { ...defaultOptions, ...options }, () => { + onReady(player); + }); + player.seekButtons({ + ...defaultSeekOptions, + ...seekOptions, + }); + + // Disable fullscreen on iOS if we have children + if ( + children && + videojs.browser.IS_IOS && + videojs.browser.IOS_VERSION > 9 && + !player.el_.ownerDocument.querySelector('.bc-iframe') + ) { + player.tech_.el_.setAttribute('playsinline', 'playsinline'); + player.tech_.supportsFullScreen = function () { + return false; + }; } - } - // shouldComponentUpdate() { - // return false; - // } + const screen = window.screen; - render() { - const { style, children } = this.props; - return ( -
No clip available
+