From 7ee63c4c7f7b34b89a5f3c3cd6cbe9efc56ede8a Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Mon, 19 Jul 2021 22:26:49 +0100 Subject: [PATCH] gomostream works! we don't want to use this ever though. --- src/components/VideoElement.js | 42 ++++++++++------- src/lib/gomostream.js | 85 +++++++++++++++++++++++----------- src/lib/unpacker.js | 46 ++++++++++++++++++ src/views/Search.js | 3 +- 4 files changed, 132 insertions(+), 44 deletions(-) create mode 100644 src/lib/unpacker.js diff --git a/src/components/VideoElement.js b/src/components/VideoElement.js index 35ec011a..9d26ff50 100644 --- a/src/components/VideoElement.js +++ b/src/components/VideoElement.js @@ -10,21 +10,23 @@ export function VideoElement({ streamUrl, loading, setProgress }) { const [error, setError] = React.useState(false); React.useEffect(() => { - setError(false) - if (!videoRef || !videoRef.current || !streamUrl || streamUrl.length === 0 || loading) return; - - const hls = new Hls(); - - if (!Hls.isSupported() && videoRef.current.canPlayType('application/vnd.apple.mpegurl')) { - videoRef.current.src = streamUrl; - return; - } else if (!Hls.isSupported()) { - setError(true) - return; + if (!streamUrl.endsWith('.mp4')) { + setError(false) + if (!videoRef || !videoRef.current || !streamUrl || streamUrl.length === 0 || loading) return; + + const hls = new Hls(); + + if (!Hls.isSupported() && videoRef.current.canPlayType('application/vnd.apple.mpegurl')) { + videoRef.current.src = streamUrl; + return; + } else if (!Hls.isSupported()) { + setError(true) + return; + } + + hls.attachMedia(videoRef.current); + hls.loadSource(streamUrl); } - - hls.attachMedia(videoRef.current); - hls.loadSource(streamUrl); }, [videoRef, streamUrl, loading]) if (error) @@ -36,7 +38,13 @@ export function VideoElement({ streamUrl, loading, setProgress }) { if (!streamUrl || streamUrl.length === 0) return No video selected - return ( -