mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-21 06:08:12 +00:00
Reduce discrepancies with upstream in Video component (#3018)
This commit is contained in:
@@ -602,6 +602,7 @@ class Status extends ImmutablePureComponent {
|
|||||||
{Component => (<Component
|
{Component => (<Component
|
||||||
preview={attachment.get('preview_url')}
|
preview={attachment.get('preview_url')}
|
||||||
frameRate={attachment.getIn(['meta', 'original', 'frame_rate'])}
|
frameRate={attachment.getIn(['meta', 'original', 'frame_rate'])}
|
||||||
|
aspectRatio={`${attachment.getIn(['meta', 'original', 'width'])} / ${attachment.getIn(['meta', 'original', 'height'])}`}
|
||||||
blurhash={attachment.get('blurhash')}
|
blurhash={attachment.get('blurhash')}
|
||||||
src={attachment.get('url')}
|
src={attachment.get('url')}
|
||||||
alt={description}
|
alt={description}
|
||||||
|
|||||||
@@ -238,7 +238,6 @@ export const DetailedStatus: React.FC<{
|
|||||||
src={attachment.get('url')}
|
src={attachment.get('url')}
|
||||||
alt={description}
|
alt={description}
|
||||||
lang={language}
|
lang={language}
|
||||||
inline
|
|
||||||
width={300}
|
width={300}
|
||||||
height={150}
|
height={150}
|
||||||
onOpenVideo={handleOpenVideo}
|
onOpenVideo={handleOpenVideo}
|
||||||
@@ -248,7 +247,6 @@ export const DetailedStatus: React.FC<{
|
|||||||
matchedFilters={status.get('matched_media_filters')}
|
matchedFilters={status.get('matched_media_filters')}
|
||||||
letterbox={letterboxMedia}
|
letterbox={letterboxMedia}
|
||||||
fullwidth={fullwidthMedia}
|
fullwidth={fullwidthMedia}
|
||||||
preventPlayback={!expanded}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
mediaIcons.push('video-camera');
|
mediaIcons.push('video-camera');
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class Video extends PureComponent {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
preview: PropTypes.string,
|
preview: PropTypes.string,
|
||||||
frameRate: PropTypes.string,
|
frameRate: PropTypes.string,
|
||||||
|
aspectRatio: PropTypes.string,
|
||||||
src: PropTypes.string.isRequired,
|
src: PropTypes.string.isRequired,
|
||||||
alt: PropTypes.string,
|
alt: PropTypes.string,
|
||||||
lang: PropTypes.string,
|
lang: PropTypes.string,
|
||||||
@@ -123,13 +124,11 @@ class Video extends PureComponent {
|
|||||||
onOpenVideo: PropTypes.func,
|
onOpenVideo: PropTypes.func,
|
||||||
onCloseVideo: PropTypes.func,
|
onCloseVideo: PropTypes.func,
|
||||||
detailed: PropTypes.bool,
|
detailed: PropTypes.bool,
|
||||||
inline: PropTypes.bool,
|
|
||||||
editable: PropTypes.bool,
|
editable: PropTypes.bool,
|
||||||
alwaysVisible: PropTypes.bool,
|
alwaysVisible: PropTypes.bool,
|
||||||
visible: PropTypes.bool,
|
visible: PropTypes.bool,
|
||||||
letterbox: PropTypes.bool,
|
letterbox: PropTypes.bool,
|
||||||
fullwidth: PropTypes.bool,
|
fullwidth: PropTypes.bool,
|
||||||
preventPlayback: PropTypes.bool,
|
|
||||||
onToggleVisibility: PropTypes.func,
|
onToggleVisibility: PropTypes.func,
|
||||||
deployPictureInPicture: PropTypes.func,
|
deployPictureInPicture: PropTypes.func,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
@@ -399,8 +398,8 @@ class Video extends PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate (prevProps) {
|
componentDidUpdate (prevProps, prevState) {
|
||||||
if (this.video && this.state.revealed && this.props.preventPlayback && !prevProps.preventPlayback) {
|
if (prevState.revealed && !this.state.revealed && this.video) {
|
||||||
this.video.pause();
|
this.video.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -471,10 +470,6 @@ class Video extends PureComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
toggleReveal = () => {
|
toggleReveal = () => {
|
||||||
if (this.state.revealed) {
|
|
||||||
this.setState({ paused: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.props.onToggleVisibility) {
|
if (this.props.onToggleVisibility) {
|
||||||
this.props.onToggleVisibility();
|
this.props.onToggleVisibility();
|
||||||
} else {
|
} else {
|
||||||
@@ -543,17 +538,11 @@ class Video extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { preview, src, inline, onOpenVideo, onCloseVideo, intl, alt, lang, letterbox, fullwidth, detailed, sensitive, editable, blurhash, autoFocus, matchedFilters } = this.props;
|
const { preview, src, aspectRatio, onOpenVideo, onCloseVideo, intl, alt, lang, letterbox, fullwidth, detailed, sensitive, editable, blurhash, autoFocus, matchedFilters } = this.props;
|
||||||
const { currentTime, duration, volume, buffer, dragging, paused, fullscreen, hovered, revealed } = this.state;
|
const { currentTime, duration, volume, buffer, dragging, paused, fullscreen, hovered, revealed } = this.state;
|
||||||
const progress = Math.min((currentTime / duration) * 100, 100);
|
const progress = Math.min((currentTime / duration) * 100, 100);
|
||||||
const muted = this.state.muted || volume === 0;
|
const muted = this.state.muted || volume === 0;
|
||||||
|
|
||||||
const playerStyle = {};
|
|
||||||
|
|
||||||
if (inline) {
|
|
||||||
playerStyle.aspectRatio = '16 / 9';
|
|
||||||
}
|
|
||||||
|
|
||||||
let preload;
|
let preload;
|
||||||
|
|
||||||
if (this.props.currentTime || fullscreen || dragging) {
|
if (this.props.currentTime || fullscreen || dragging) {
|
||||||
@@ -564,11 +553,13 @@ class Video extends PureComponent {
|
|||||||
preload = 'none';
|
preload = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The outer wrapper is necessary to avoid reflowing the layout when going into full screen
|
||||||
return (
|
return (
|
||||||
|
<div style={{ aspectRatio }}>
|
||||||
<div
|
<div
|
||||||
role='menuitem'
|
role='menuitem'
|
||||||
className={classNames('video-player', { inactive: !revealed, detailed, inline: inline && !fullscreen, fullscreen, editable, letterbox, 'full-width': fullwidth })}
|
className={classNames('video-player', { inactive: !revealed, detailed, fullscreen, editable, letterbox, 'full-width': fullwidth })}
|
||||||
style={playerStyle}
|
style={{ aspectRatio }}
|
||||||
ref={this.setPlayerRef}
|
ref={this.setPlayerRef}
|
||||||
onMouseEnter={this.handleMouseEnter}
|
onMouseEnter={this.handleMouseEnter}
|
||||||
onMouseLeave={this.handleMouseLeave}
|
onMouseLeave={this.handleMouseLeave}
|
||||||
@@ -601,7 +592,7 @@ class Video extends PureComponent {
|
|||||||
onLoadedData={this.handleLoadedData}
|
onLoadedData={this.handleLoadedData}
|
||||||
onProgress={this.handleProgress}
|
onProgress={this.handleProgress}
|
||||||
onVolumeChange={this.handleVolumeChange}
|
onVolumeChange={this.handleVolumeChange}
|
||||||
style={{ ...playerStyle, width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
/>}
|
/>}
|
||||||
|
|
||||||
<SpoilerButton hidden={revealed || editable} sensitive={sensitive} onClick={this.toggleReveal} matchedFilters={matchedFilters} />
|
<SpoilerButton hidden={revealed || editable} sensitive={sensitive} onClick={this.toggleReveal} matchedFilters={matchedFilters} />
|
||||||
@@ -652,6 +643,7 @@ class Video extends PureComponent {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user