2017-05-02 19:04:16 -05:00
|
|
|
import React from 'react';
|
2017-04-13 08:04:18 -05:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-04-21 13:05:35 -05:00
|
|
|
import PropTypes from 'prop-types';
|
2019-05-03 09:16:30 -05:00
|
|
|
import Video from 'mastodon/features/video';
|
2017-05-02 19:04:16 -05:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2020-12-06 21:29:37 -06:00
|
|
|
import Footer from 'mastodon/features/picture_in_picture/components/footer';
|
|
|
|
import { getAverageFromBlurhash } from 'mastodon/blurhash';
|
2019-05-03 09:16:30 -05:00
|
|
|
|
2017-06-23 12:36:54 -05:00
|
|
|
export default class VideoModal extends ImmutablePureComponent {
|
2017-04-13 08:04:18 -05:00
|
|
|
|
2017-05-12 07:44:10 -05:00
|
|
|
static propTypes = {
|
|
|
|
media: ImmutablePropTypes.map.isRequired,
|
2020-11-26 20:24:11 -06:00
|
|
|
statusId: PropTypes.string,
|
2020-04-25 05:16:05 -05:00
|
|
|
options: PropTypes.shape({
|
|
|
|
startTime: PropTypes.number,
|
|
|
|
autoPlay: PropTypes.bool,
|
|
|
|
defaultVolume: PropTypes.number,
|
|
|
|
}),
|
2017-05-12 07:44:10 -05:00
|
|
|
onClose: PropTypes.func.isRequired,
|
2020-12-06 21:29:37 -06:00
|
|
|
onChangeBackgroundColor: PropTypes.func.isRequired,
|
2017-05-12 07:44:10 -05:00
|
|
|
};
|
|
|
|
|
2019-05-03 09:16:30 -05:00
|
|
|
componentDidMount () {
|
2020-12-06 21:29:37 -06:00
|
|
|
const { media, onChangeBackgroundColor, onClose } = this.props;
|
2019-05-03 09:16:30 -05:00
|
|
|
|
2020-12-06 21:29:37 -06:00
|
|
|
const backgroundColor = getAverageFromBlurhash(media.get('blurhash'));
|
2019-05-03 09:16:30 -05:00
|
|
|
|
2020-12-06 21:29:37 -06:00
|
|
|
if (backgroundColor) {
|
|
|
|
onChangeBackgroundColor(backgroundColor);
|
2019-05-03 09:16:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 08:04:18 -05:00
|
|
|
render () {
|
2020-12-06 21:29:37 -06:00
|
|
|
const { media, statusId, onClose } = this.props;
|
2020-04-25 05:16:05 -05:00
|
|
|
const options = this.props.options || {};
|
2019-05-03 09:16:30 -05:00
|
|
|
|
2017-04-13 08:04:18 -05:00
|
|
|
return (
|
2018-03-04 13:32:24 -06:00
|
|
|
<div className='modal-root__modal video-modal'>
|
2019-10-02 20:34:58 -05:00
|
|
|
<div className='video-modal__container'>
|
2017-09-13 20:39:10 -05:00
|
|
|
<Video
|
|
|
|
preview={media.get('preview_url')}
|
2020-11-21 16:19:04 -06:00
|
|
|
frameRate={media.getIn(['meta', 'original', 'frame_rate'])}
|
2019-04-26 20:24:09 -05:00
|
|
|
blurhash={media.get('blurhash')}
|
2017-09-13 20:39:10 -05:00
|
|
|
src={media.get('url')}
|
2020-09-28 06:29:43 -05:00
|
|
|
currentTime={options.startTime}
|
2020-04-25 05:16:05 -05:00
|
|
|
autoPlay={options.autoPlay}
|
2020-09-28 06:29:43 -05:00
|
|
|
volume={options.defaultVolume}
|
2017-09-13 20:39:10 -05:00
|
|
|
onCloseVideo={onClose}
|
2017-12-08 17:55:58 -06:00
|
|
|
detailed
|
2018-09-13 13:31:59 -05:00
|
|
|
alt={media.get('description')}
|
2017-09-13 20:39:10 -05:00
|
|
|
/>
|
2017-04-13 08:04:18 -05:00
|
|
|
</div>
|
2020-12-06 21:29:37 -06:00
|
|
|
|
|
|
|
<div className='media-modal__overlay'>
|
|
|
|
{statusId && <Footer statusId={statusId} withOpenButton onClose={onClose} />}
|
|
|
|
</div>
|
2017-04-13 08:04:18 -05:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-21 13:05:35 -05:00
|
|
|
}
|