mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 00:56:23 +01:00
Attempt to fix video not autoplaying on Mobile Safari
This commit is contained in:
parent
42fa30d8f8
commit
c4efc26d62
1 changed files with 11 additions and 13 deletions
|
@ -743,30 +743,35 @@ function Media({ media, showOriginal, onClick = () => {} }) {
|
|||
rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`,
|
||||
}}
|
||||
onClick={(e) => {
|
||||
if (isGIF) {
|
||||
if (showOriginal && isGIF) {
|
||||
try {
|
||||
videoRef.current?.pause();
|
||||
if (videoRef.current.paused) {
|
||||
videoRef.current.play();
|
||||
} else {
|
||||
videoRef.current.pause();
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
onClick(e);
|
||||
}}
|
||||
onMouseEnter={() => {
|
||||
if (isGIF) {
|
||||
if (!showOriginal && isGIF) {
|
||||
try {
|
||||
videoRef.current?.play();
|
||||
videoRef.current.play();
|
||||
} catch (e) {}
|
||||
}
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
if (isGIF) {
|
||||
if (!showOriginal && isGIF) {
|
||||
try {
|
||||
videoRef.current?.pause();
|
||||
videoRef.current.pause();
|
||||
} catch (e) {}
|
||||
}
|
||||
}}
|
||||
>
|
||||
{showOriginal ? (
|
||||
<video
|
||||
ref={videoRef}
|
||||
src={url}
|
||||
poster={previewUrl}
|
||||
width={width}
|
||||
|
@ -777,13 +782,6 @@ function Media({ media, showOriginal, onClick = () => {} }) {
|
|||
controls={!isGIF}
|
||||
playsinline
|
||||
loop={loopable}
|
||||
onClick={() => {
|
||||
if (isGIF) {
|
||||
try {
|
||||
videoRef.current?.play();
|
||||
} catch (e) {}
|
||||
}
|
||||
}}
|
||||
></video>
|
||||
) : isGIF ? (
|
||||
<video
|
||||
|
|
Loading…
Reference in a new issue