mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 09:06: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(',')})`,
|
rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`,
|
||||||
}}
|
}}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (isGIF) {
|
if (showOriginal && isGIF) {
|
||||||
try {
|
try {
|
||||||
videoRef.current?.pause();
|
if (videoRef.current.paused) {
|
||||||
|
videoRef.current.play();
|
||||||
|
} else {
|
||||||
|
videoRef.current.pause();
|
||||||
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
onClick(e);
|
onClick(e);
|
||||||
}}
|
}}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
if (isGIF) {
|
if (!showOriginal && isGIF) {
|
||||||
try {
|
try {
|
||||||
videoRef.current?.play();
|
videoRef.current.play();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onMouseLeave={() => {
|
onMouseLeave={() => {
|
||||||
if (isGIF) {
|
if (!showOriginal && isGIF) {
|
||||||
try {
|
try {
|
||||||
videoRef.current?.pause();
|
videoRef.current.pause();
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{showOriginal ? (
|
{showOriginal ? (
|
||||||
<video
|
<video
|
||||||
|
ref={videoRef}
|
||||||
src={url}
|
src={url}
|
||||||
poster={previewUrl}
|
poster={previewUrl}
|
||||||
width={width}
|
width={width}
|
||||||
|
@ -777,13 +782,6 @@ function Media({ media, showOriginal, onClick = () => {} }) {
|
||||||
controls={!isGIF}
|
controls={!isGIF}
|
||||||
playsinline
|
playsinline
|
||||||
loop={loopable}
|
loop={loopable}
|
||||||
onClick={() => {
|
|
||||||
if (isGIF) {
|
|
||||||
try {
|
|
||||||
videoRef.current?.play();
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
></video>
|
></video>
|
||||||
) : isGIF ? (
|
) : isGIF ? (
|
||||||
<video
|
<video
|
||||||
|
|
Loading…
Reference in a new issue