2017-04-21 18:05:35 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 14:38:10 +00:00
|
|
|
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-05-03 00:04:16 +00:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2023-05-28 14:38:10 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
2020-12-07 03:29:37 +00:00
|
|
|
import { getAverageFromBlurhash } from 'flavours/glitch/blurhash';
|
2023-05-28 14:38:10 +00:00
|
|
|
import Footer from 'flavours/glitch/features/picture_in_picture/components/footer';
|
|
|
|
import Video from 'flavours/glitch/features/video';
|
2017-04-13 13:04:18 +00:00
|
|
|
|
2023-02-26 19:13:27 +00:00
|
|
|
const mapStateToProps = (state, { statusId }) => ({
|
|
|
|
language: state.getIn(['statuses', statusId, 'language']),
|
|
|
|
});
|
|
|
|
|
|
|
|
class VideoModal extends ImmutablePureComponent {
|
2017-04-13 13:04:18 +00:00
|
|
|
|
2017-05-12 12:44:10 +00:00
|
|
|
static propTypes = {
|
|
|
|
media: ImmutablePropTypes.map.isRequired,
|
2020-11-27 02:24:11 +00:00
|
|
|
statusId: PropTypes.string,
|
2023-02-26 19:13:27 +00:00
|
|
|
language: PropTypes.string,
|
2020-04-25 10:16:05 +00:00
|
|
|
options: PropTypes.shape({
|
|
|
|
startTime: PropTypes.number,
|
|
|
|
autoPlay: PropTypes.bool,
|
|
|
|
defaultVolume: PropTypes.number,
|
|
|
|
}),
|
2017-05-12 12:44:10 +00:00
|
|
|
onClose: PropTypes.func.isRequired,
|
2020-12-07 03:29:37 +00:00
|
|
|
onChangeBackgroundColor: PropTypes.func.isRequired,
|
2017-05-12 12:44:10 +00:00
|
|
|
};
|
|
|
|
|
2020-12-07 03:29:37 +00:00
|
|
|
componentDidMount () {
|
2023-05-07 16:22:25 +00:00
|
|
|
const { media, onChangeBackgroundColor } = this.props;
|
2020-12-07 03:29:37 +00:00
|
|
|
|
|
|
|
const backgroundColor = getAverageFromBlurhash(media.get('blurhash'));
|
|
|
|
|
|
|
|
if (backgroundColor) {
|
|
|
|
onChangeBackgroundColor(backgroundColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 13:04:18 +00:00
|
|
|
render () {
|
2023-02-26 19:13:27 +00:00
|
|
|
const { media, statusId, language, onClose } = this.props;
|
2020-04-25 10:16:05 +00:00
|
|
|
const options = this.props.options || {};
|
2019-05-03 14:16:30 +00:00
|
|
|
|
2017-04-13 13:04:18 +00:00
|
|
|
return (
|
2018-04-08 21:15:25 +00:00
|
|
|
<div className='modal-root__modal video-modal'>
|
2019-10-03 01:34:58 +00:00
|
|
|
<div className='video-modal__container'>
|
2017-09-14 01:39:10 +00:00
|
|
|
<Video
|
|
|
|
preview={media.get('preview_url')}
|
2020-11-21 22:19:04 +00:00
|
|
|
frameRate={media.getIn(['meta', 'original', 'frame_rate'])}
|
2019-04-27 01:24:09 +00:00
|
|
|
blurhash={media.get('blurhash')}
|
2017-09-14 01:39:10 +00:00
|
|
|
src={media.get('url')}
|
2020-09-28 11:29:43 +00:00
|
|
|
currentTime={options.startTime}
|
2020-04-25 10:16:05 +00:00
|
|
|
autoPlay={options.autoPlay}
|
2020-09-28 11:29:43 +00:00
|
|
|
volume={options.defaultVolume}
|
2017-09-14 01:39:10 +00:00
|
|
|
onCloseVideo={onClose}
|
2023-01-09 02:52:37 +00:00
|
|
|
autoFocus
|
2018-01-13 18:41:20 +00:00
|
|
|
detailed
|
2018-09-11 13:45:51 +00:00
|
|
|
alt={media.get('description')}
|
2023-02-26 19:13:27 +00:00
|
|
|
lang={language}
|
2017-09-14 01:39:10 +00:00
|
|
|
/>
|
2017-04-13 13:04:18 +00:00
|
|
|
</div>
|
2020-12-07 03:29:37 +00:00
|
|
|
|
|
|
|
<div className='media-modal__overlay'>
|
|
|
|
{statusId && <Footer statusId={statusId} withOpenButton onClose={onClose} />}
|
|
|
|
</div>
|
2017-04-13 13:04:18 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-21 18:05:35 +00:00
|
|
|
}
|
2023-03-24 22:15:25 +00:00
|
|
|
|
|
|
|
export default connect(mapStateToProps, null, null, { forwardRef: true })(VideoModal);
|