2017-05-03 09:04:16 +09:00
|
|
|
import React from 'react';
|
2017-04-13 22:04:18 +09:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-04-22 03:05:35 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2017-12-04 16:26:40 +09:00
|
|
|
import Video from 'flavours/glitch/features/video';
|
2017-05-03 09:04:16 +09:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2019-05-03 23:16:30 +09:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2019-10-03 10:34:58 +09:00
|
|
|
import classNames from 'classnames';
|
2019-12-07 23:53:04 +09:00
|
|
|
import Icon from 'flavours/glitch/components/icon';
|
2017-04-13 22:04:18 +09:00
|
|
|
|
2017-06-24 02:36:54 +09:00
|
|
|
export default class VideoModal extends ImmutablePureComponent {
|
2017-04-13 22:04:18 +09:00
|
|
|
|
2019-05-03 23:16:30 +09:00
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
2017-05-12 21:44:10 +09:00
|
|
|
static propTypes = {
|
|
|
|
media: ImmutablePropTypes.map.isRequired,
|
2019-05-03 23:16:30 +09:00
|
|
|
status: ImmutablePropTypes.map,
|
2020-04-25 19:16:05 +09:00
|
|
|
options: PropTypes.shape({
|
|
|
|
startTime: PropTypes.number,
|
|
|
|
autoPlay: PropTypes.bool,
|
|
|
|
defaultVolume: PropTypes.number,
|
|
|
|
}),
|
2017-05-12 21:44:10 +09:00
|
|
|
onClose: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
2019-05-03 23:16:30 +09:00
|
|
|
handleStatusClick = e => {
|
|
|
|
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
|
|
|
e.preventDefault();
|
|
|
|
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 22:04:18 +09:00
|
|
|
render () {
|
2020-04-25 19:16:05 +09:00
|
|
|
const { media, status, onClose } = this.props;
|
|
|
|
const options = this.props.options || {};
|
2019-05-03 23:16:30 +09:00
|
|
|
|
2017-04-13 22:04:18 +09:00
|
|
|
return (
|
2018-04-09 06:15:25 +09:00
|
|
|
<div className='modal-root__modal video-modal'>
|
2019-10-03 10:34:58 +09:00
|
|
|
<div className='video-modal__container'>
|
2017-09-14 10:39:10 +09:00
|
|
|
<Video
|
|
|
|
preview={media.get('preview_url')}
|
2020-11-22 07:19:04 +09:00
|
|
|
frameRate={media.getIn(['meta', 'original', 'frame_rate'])}
|
2019-04-27 10:24:09 +09:00
|
|
|
blurhash={media.get('blurhash')}
|
2017-09-14 10:39:10 +09:00
|
|
|
src={media.get('url')}
|
2020-09-28 20:29:43 +09:00
|
|
|
currentTime={options.startTime}
|
2020-04-25 19:16:05 +09:00
|
|
|
autoPlay={options.autoPlay}
|
2020-09-28 20:29:43 +09:00
|
|
|
volume={options.defaultVolume}
|
2017-09-14 10:39:10 +09:00
|
|
|
onCloseVideo={onClose}
|
2018-01-14 03:41:20 +09:00
|
|
|
detailed
|
2018-09-11 22:45:51 +09:00
|
|
|
alt={media.get('description')}
|
2017-09-14 10:39:10 +09:00
|
|
|
/>
|
2017-04-13 22:04:18 +09:00
|
|
|
</div>
|
2019-10-03 10:34:58 +09:00
|
|
|
|
|
|
|
{status && (
|
|
|
|
<div className={classNames('media-modal__meta')}>
|
|
|
|
<a href={status.get('url')} onClick={this.handleStatusClick}><Icon id='comments' /> <FormattedMessage id='lightbox.view_context' defaultMessage='View context' /></a>
|
|
|
|
</div>
|
|
|
|
)}
|
2017-04-13 22:04:18 +09:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-22 03:05:35 +09:00
|
|
|
}
|