Attempt to fix videos not autoplaying on Mobile Safari

Fallback onClick to play in case it really still doesn't autoplay
This commit is contained in:
Lim Chee Aun 2022-12-12 10:00:59 +08:00
parent 0289d20d8b
commit 299b638ac3

View file

@ -126,12 +126,19 @@ function Media({ media, showOriginal, onClick }) {
poster={previewUrl} poster={previewUrl}
width={width} width={width}
height={height} height={height}
preload preload="auto"
autoplay autoplay
muted={isGIF} muted={isGIF}
controls={!isGIF} controls={!isGIF}
playsinline playsinline
loop loop
onClick={() => {
if (isGIF) {
try {
videoRef.current?.play();
} catch (e) {}
}
}}
></video> ></video>
) : isGIF ? ( ) : isGIF ? (
<video <video
@ -140,7 +147,7 @@ function Media({ media, showOriginal, onClick }) {
poster={previewUrl} poster={previewUrl}
width={width} width={width}
height={height} height={height}
preload preload="auto"
// controls // controls
playsinline playsinline
loop loop