Another attempt at fixing GIF not autoplaying on Mobile Safari

This commit is contained in:
Lim Chee Aun 2022-12-26 01:09:19 +08:00
parent c8ea2e8703
commit 9278645069
2 changed files with 14 additions and 8 deletions

View file

@ -374,6 +374,7 @@
} }
.status .media-gif video { .status .media-gif video {
object-fit: cover; object-fit: cover;
pointer-events: none;
} }
.status .media-audio { .status .media-audio {
border: 0; border: 0;

View file

@ -755,14 +755,19 @@ function Media({ media, showOriginal, onClick = () => {} }) {
rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`, rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`,
}} }}
onClick={(e) => { onClick={(e) => {
if (showOriginal && isGIF) { if (isGIF) {
try { // Hmm, the videoRef might conflict here
if (videoRef.current.paused) { if (showOriginal) {
videoRef.current.play(); try {
} else { if (videoRef.current.paused) {
videoRef.current.pause(); videoRef.current.play();
} } else {
} catch (e) {} videoRef.current.pause();
}
} catch (e) {}
} else {
videoRef.current.pause();
}
} }
onClick(e); onClick(e);
}} }}