From 03a4512326a20661f186c6e7e8f40a207b3e75f4 Mon Sep 17 00:00:00 2001 From: Saliou Diallo Date: Mon, 12 Apr 2021 14:03:31 -0400 Subject: [PATCH] Fix iOS safari video thumbnail and limit video support (#374) * Limit collectible video formats supported * Fix iOS video inline autoplay * Add comments Co-authored-by: Saliou Diallo --- .../components/CollectiblesPage.tsx | 27 ++++- .../src/containers/collectibles/helpers.ts | 107 +++++++++--------- 2 files changed, 79 insertions(+), 55 deletions(-) diff --git a/packages/audius-web-client/src/containers/collectibles/components/CollectiblesPage.tsx b/packages/audius-web-client/src/containers/collectibles/components/CollectiblesPage.tsx index b9554aeb67..4e15ce3c53 100644 --- a/packages/audius-web-client/src/containers/collectibles/components/CollectiblesPage.tsx +++ b/packages/audius-web-client/src/containers/collectibles/components/CollectiblesPage.tsx @@ -111,6 +111,26 @@ const CollectibleDetails: React.FC<{ setIsMuted(!isMuted) }, [isMuted, setIsMuted]) + const videoRef = useRef(null) + + useEffect(() => { + if (videoRef?.current) { + const videoElement = videoRef.current + const listener = () => { + videoElement.pause() + } + ;['loadeddata', 'timeupdate'].forEach(event => { + videoElement.addEventListener(event, listener) + }) + + return () => { + ;['loadeddata', 'timeupdate'].forEach(event => { + videoElement.removeEventListener(event, listener) + }) + } + } + }, [videoRef]) + return (