[Glitch] fix gif autoplay on iOS

Port c0dcf15d1e to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
main
James Adney 2022-11-27 11:46:23 -08:00 committed by Claire
parent c0bf90ac19
commit 2815ac4155
2 changed files with 4 additions and 4 deletions

View File

@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
import { is } from 'immutable'; import { is } from 'immutable';
import IconButton from './icon_button'; import IconButton from './icon_button';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import { isIOS } from '../is_mobile';
import classNames from 'classnames'; import classNames from 'classnames';
import { autoPlayGif, displayMedia, useBlurhash } from 'flavours/glitch/initial_state'; import { autoPlayGif, displayMedia, useBlurhash } from 'flavours/glitch/initial_state';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
@ -202,7 +201,7 @@ class Item extends React.PureComponent {
</a> </a>
); );
} else if (attachment.get('type') === 'gifv') { } else if (attachment.get('type') === 'gifv') {
const autoPlay = !isIOS() && this.getAutoPlay(); const autoPlay = this.getAutoPlay();
thumbnail = ( thumbnail = (
<div className={classNames('media-gallery__gifv', { autoplay: autoPlay })}> <div className={classNames('media-gallery__gifv', { autoplay: autoPlay })}>
@ -216,6 +215,7 @@ class Item extends React.PureComponent {
onMouseEnter={this.handleMouseEnter} onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave} onMouseLeave={this.handleMouseLeave}
autoPlay={autoPlay} autoPlay={autoPlay}
playsInline
loop loop
muted muted
/> />

View File

@ -2,7 +2,6 @@ import Blurhash from 'flavours/glitch/components/blurhash';
import classNames from 'classnames'; import classNames from 'classnames';
import Icon from 'flavours/glitch/components/icon'; import Icon from 'flavours/glitch/components/icon';
import { autoPlayGif, displayMedia, useBlurhash } from 'flavours/glitch/initial_state'; import { autoPlayGif, displayMedia, useBlurhash } from 'flavours/glitch/initial_state';
import { isIOS } from 'flavours/glitch/is_mobile';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
@ -109,7 +108,8 @@ export default class MediaItem extends ImmutablePureComponent {
src={attachment.get('url')} src={attachment.get('url')}
onMouseEnter={this.handleMouseEnter} onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave} onMouseLeave={this.handleMouseLeave}
autoPlay={!isIOS() && autoPlayGif} autoPlay={autoPlayGif}
playsInline
loop loop
muted muted
/> />