From 40ee5bb012869172a1365ddf62f9e46cfda324cf Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Sat, 7 Aug 2021 21:19:01 +0100 Subject: [PATCH] new code --- src/components/VideoElement.js | 14 +++++++++++--- src/views/Movie.js | 30 ++++++++++-------------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/components/VideoElement.js b/src/components/VideoElement.js index f5b380a4..13426eb0 100644 --- a/src/components/VideoElement.js +++ b/src/components/VideoElement.js @@ -6,9 +6,17 @@ import './VideoElement.css' // streamUrl: string // loading: boolean -export function VideoElement({ streamUrl, loading, setProgress, videoRef }) { +// setProgress: (event: NativeEvent) => void +// videoRef: useRef +// startTime: number +export function VideoElement({ streamUrl, loading, setProgress, videoRef, startTime }) { const [error, setError] = React.useState(false); + function onLoad() { + if (startTime) + videoRef.current.currentTime = startTime; + } + React.useEffect(() => { if (!streamUrl.endsWith('.mp4')) { setError(false) @@ -40,11 +48,11 @@ export function VideoElement({ streamUrl, loading, setProgress, videoRef }) { if (!streamUrl.endsWith('.mp4')) { return ( -