Fix video display in media gallery

This commit is contained in:
Alex Gleason 2021-05-17 22:17:10 -05:00
parent a5f9ff08cb
commit 66a491d298
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 38 additions and 0 deletions

View File

@ -123,6 +123,16 @@ class Item extends React.PureComponent {
this.setState({ loaded: true });
}
handleVideoHover = ({ target: video }) => {
video.playbackRate = 3.0;
video.play();
}
handleVideoLeave = ({ target: video }) => {
video.pause();
video.currentTime = 0;
}
render() {
const { attachment, standalone, visible, dimensions, autoPlayGif, last, total } = this.props;
@ -221,6 +231,28 @@ class Item extends React.PureComponent {
<span className='media-gallery__file-extension__label'>{fileExtension}</span>
</a>
);
} else if (attachment.get('type') === 'video') {
const ext = attachment.get('url').split('.').pop().toUpperCase();
thumbnail = (
<a
className={classNames('media-gallery__item-thumbnail')}
href={attachment.get('url')}
onClick={this.handleClick}
target='_blank'
alt={attachment.get('description')}
title={attachment.get('description')}
>
<video
muted
loop
onMouseOver={this.handleVideoHover}
onMouseOut={this.handleVideoLeave}
>
<source src={attachment.get('url')} />
</video>
<span className='media-gallery__file-extension__label'>{ext}</span>
</a>
);
}
return (

View File

@ -82,6 +82,12 @@
transition: opacity 0.1s ease;
line-height: 18px;
}
video {
width: 100%;
height: 100%;
object-fit: cover;
}
}
.status__wrapper,