mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-16 23:31:19 +03:00
Make GIF autoplay on Mobile Safari
Only in carousel, and seems like `autoplay` with `muted` ain't working in (P)react.
This commit is contained in:
parent
23a6cdbe3b
commit
422a924844
1 changed files with 21 additions and 25 deletions
|
@ -759,19 +759,10 @@ function Media({ media, showOriginal, onClick = () => {} }) {
|
|||
rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`,
|
||||
}}
|
||||
onClick={(e) => {
|
||||
if (isGIF) {
|
||||
// Hmm, the videoRef might conflict here
|
||||
if (showOriginal) {
|
||||
try {
|
||||
if (videoRef.current.paused) {
|
||||
videoRef.current.play();
|
||||
} else {
|
||||
videoRef.current.pause();
|
||||
}
|
||||
} catch (e) {}
|
||||
} else {
|
||||
if (!showOriginal && isGIF) {
|
||||
try {
|
||||
videoRef.current.pause();
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
onClick(e);
|
||||
}}
|
||||
|
@ -791,19 +782,24 @@ function Media({ media, showOriginal, onClick = () => {} }) {
|
|||
}}
|
||||
>
|
||||
{showOriginal ? (
|
||||
<video
|
||||
ref={videoRef}
|
||||
src={url}
|
||||
poster={previewUrl}
|
||||
width={width}
|
||||
height={height}
|
||||
preload="auto"
|
||||
autoplay
|
||||
muted={isGIF}
|
||||
controls={!isGIF}
|
||||
playsinline
|
||||
loop={loopable}
|
||||
></video>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
<video
|
||||
src="${url}"
|
||||
poster="${previewUrl}"
|
||||
width="${width}"
|
||||
height="${height}"
|
||||
preload="auto"
|
||||
autoplay
|
||||
muted="${isGIF}"
|
||||
${isGIF ? '' : 'controls'}
|
||||
playsinline
|
||||
loop="${loopable}"
|
||||
></video>
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
) : isGIF ? (
|
||||
<video
|
||||
ref={videoRef}
|
||||
|
|
Loading…
Add table
Reference in a new issue