Browse Source

Pause video playback if toot is collapsed or CWs folded (fixes #146)

closed-social-glitch-2
Thibaut Girka 6 years ago
committed by ThibG
parent
commit
d8b2f15b23
2 changed files with 8 additions and 0 deletions
  1. +1
    -0
      app/javascript/flavours/glitch/components/status.js
  2. +7
    -0
      app/javascript/flavours/glitch/features/video/index.js

+ 1
- 0
app/javascript/flavours/glitch/components/status.js View File

@ -430,6 +430,7 @@ export default class Status extends ImmutablePureComponent {
sensitive={status.get('sensitive')} sensitive={status.get('sensitive')}
letterbox={settings.getIn(['media', 'letterbox'])} letterbox={settings.getIn(['media', 'letterbox'])}
fullwidth={settings.getIn(['media', 'fullwidth'])} fullwidth={settings.getIn(['media', 'fullwidth'])}
preventPlayback={isCollapsed || !isExpanded}
onOpenVideo={this.handleOpenVideo} onOpenVideo={this.handleOpenVideo}
/>)} />)}
</Bundle> </Bundle>

+ 7
- 0
app/javascript/flavours/glitch/features/video/index.js View File

@ -101,6 +101,7 @@ export default class Video extends React.PureComponent {
fullwidth: PropTypes.bool, fullwidth: PropTypes.bool,
detailed: PropTypes.bool, detailed: PropTypes.bool,
inline: PropTypes.bool, inline: PropTypes.bool,
preventPlayback: PropTypes.bool,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
}; };
@ -215,6 +216,12 @@ export default class Video extends React.PureComponent {
document.removeEventListener('MSFullscreenChange', this.handleFullscreenChange, true); document.removeEventListener('MSFullscreenChange', this.handleFullscreenChange, true);
} }
componentDidUpdate (prevProps) {
if (this.video && this.state.revealed && this.props.preventPlayback && !prevProps.preventPlayback) {
this.video.pause();
}
}
handleFullscreenChange = () => { handleFullscreenChange = () => {
this.setState({ fullscreen: isFullscreen() }); this.setState({ fullscreen: isFullscreen() });
} }

Loading…
Cancel
Save