You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
63 lines
1.9 KiB
8 years ago
|
import React from 'react';
|
||
8 years ago
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
8 years ago
|
import PropTypes from 'prop-types';
|
||
6 years ago
|
import Video from 'mastodon/features/video';
|
||
8 years ago
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||
4 years ago
|
import Footer from 'mastodon/features/picture_in_picture/components/footer';
|
||
|
import { getAverageFromBlurhash } from 'mastodon/blurhash';
|
||
6 years ago
|
|
||
7 years ago
|
export default class VideoModal extends ImmutablePureComponent {
|
||
8 years ago
|
|
||
8 years ago
|
static propTypes = {
|
||
|
media: ImmutablePropTypes.map.isRequired,
|
||
4 years ago
|
statusId: PropTypes.string,
|
||
5 years ago
|
options: PropTypes.shape({
|
||
|
startTime: PropTypes.number,
|
||
|
autoPlay: PropTypes.bool,
|
||
|
defaultVolume: PropTypes.number,
|
||
|
}),
|
||
8 years ago
|
onClose: PropTypes.func.isRequired,
|
||
4 years ago
|
onChangeBackgroundColor: PropTypes.func.isRequired,
|
||
8 years ago
|
};
|
||
|
|
||
6 years ago
|
componentDidMount () {
|
||
3 years ago
|
const { media, onChangeBackgroundColor } = this.props;
|
||
6 years ago
|
|
||
4 years ago
|
const backgroundColor = getAverageFromBlurhash(media.get('blurhash'));
|
||
6 years ago
|
|
||
4 years ago
|
if (backgroundColor) {
|
||
|
onChangeBackgroundColor(backgroundColor);
|
||
6 years ago
|
}
|
||
|
}
|
||
|
|
||
8 years ago
|
render () {
|
||
4 years ago
|
const { media, statusId, onClose } = this.props;
|
||
5 years ago
|
const options = this.props.options || {};
|
||
6 years ago
|
|
||
8 years ago
|
return (
|
||
7 years ago
|
<div className='modal-root__modal video-modal'>
|
||
5 years ago
|
<div className='video-modal__container'>
|
||
7 years ago
|
<Video
|
||
|
preview={media.get('preview_url')}
|
||
4 years ago
|
frameRate={media.getIn(['meta', 'original', 'frame_rate'])}
|
||
6 years ago
|
blurhash={media.get('blurhash')}
|
||
7 years ago
|
src={media.get('url')}
|
||
4 years ago
|
currentTime={options.startTime}
|
||
5 years ago
|
autoPlay={options.autoPlay}
|
||
4 years ago
|
volume={options.defaultVolume}
|
||
7 years ago
|
onCloseVideo={onClose}
|
||
2 years ago
|
autoFocus
|
||
7 years ago
|
detailed
|
||
6 years ago
|
alt={media.get('description')}
|
||
7 years ago
|
/>
|
||
8 years ago
|
</div>
|
||
4 years ago
|
|
||
|
<div className='media-modal__overlay'>
|
||
|
{statusId && <Footer statusId={statusId} withOpenButton onClose={onClose} />}
|
||
|
</div>
|
||
8 years ago
|
</div>
|
||
|
);
|
||
|
}
|
||
|
|
||
8 years ago
|
}
|