return <div className='audio-player' style={{ height: '110px' }} />;
}
- handleOpenVideo = (media, startTime) => {
- this.props.onOpenVideo(media, startTime);
+ handleOpenVideo = (media, options) => {
+ this.props.onOpenVideo(media, options);
}
handleHotkeyOpenMedia = e => {
if (status.getIn(['media_attachments', 0, 'type']) === 'audio') {
// TODO: toggle play/paused?
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
- onOpenVideo(status.getIn(['media_attachments', 0]), 0);
+ onOpenVideo(status.getIn(['media_attachments', 0]), { startTime: 0 });
} else {
onOpenMedia(status.get('media_attachments'), 0);
}
dispatch(openModal('MEDIA', { media, index }));
},
- onOpenVideo (media, time) {
- dispatch(openModal('VIDEO', { media, time }));
+ onOpenVideo (media, options) {
+ dispatch(openModal('VIDEO', { media, options }));
},
onBlock (status) {
e.stopPropagation();
}
- handleOpenVideo = (media, startTime) => {
- this.props.onOpenVideo(media, startTime);
+ handleOpenVideo = (media, options) => {
+ this.props.onOpenVideo(media, options);
}
handleExpandedToggle = () => {
dispatch(openModal('MEDIA', { media, index }));
},
- onOpenVideo (media, time) {
- dispatch(openModal('VIDEO', { media, time }));
+ onOpenVideo (media, options) {
+ dispatch(openModal('VIDEO', { media, options }));
},
onBlock (status) {
this.props.dispatch(openModal('MEDIA', { media, index }));
}
- handleOpenVideo = (media, time) => {
- this.props.dispatch(openModal('VIDEO', { media, time }));
+ handleOpenVideo = (media, options) => {
+ this.props.dispatch(openModal('VIDEO', { media, options }));
}
handleHotkeyOpenMedia = e => {
if (status.getIn(['media_attachments', 0, 'type']) === 'audio') {
// TODO: toggle play/paused?
} else if (status.getIn(['media_attachments', 0, 'type']) === 'video') {
- this.handleOpenVideo(status.getIn(['media_attachments', 0]), 0);
+ this.handleOpenVideo(status.getIn(['media_attachments', 0]), { startTime: 0 });
} else {
this.handleOpenMedia(status.get('media_attachments'), 0);
}
static propTypes = {
media: ImmutablePropTypes.map.isRequired,
status: ImmutablePropTypes.map,
- time: PropTypes.number,
+ options: PropTypes.shape({
+ startTime: PropTypes.number,
+ autoPlay: PropTypes.bool,
+ defaultVolume: PropTypes.number,
+ }),
onClose: PropTypes.func.isRequired,
};
}
render () {
- const { media, status, time, onClose } = this.props;
+ const { media, status, onClose } = this.props;
+ const options = this.props.options || {};
return (
<div className='modal-root__modal video-modal'>
preview={media.get('preview_url')}
blurhash={media.get('blurhash')}
src={media.get('url')}
- startTime={time}
+ startTime={options.startTime}
+ autoPlay={options.autoPlay}
+ defaultVolume={options.defaultVolume}
onCloseVideo={onClose}
detailed
alt={media.get('description')}
intl: PropTypes.object.isRequired,
blurhash: PropTypes.string,
link: PropTypes.node,
+ autoPlay: PropTypes.bool,
+ defaultVolume: PropTypes.number,
};
state = {
handleLoadedData = () => {
if (this.props.startTime) {
this.video.currentTime = this.props.startTime;
+ }
+
+ if (this.props.defaultVolume !== undefined) {
+ this.video.volume = this.props.defaultVolume;
+ }
+
+ if (this.props.autoPlay) {
this.video.play();
}
}
height,
});
+ const options = {
+ startTime: this.video.currentTime,
+ autoPlay: !this.state.paused,
+ defaultVolume: this.state.volume,
+ };
+
this.video.pause();
- this.props.onOpenVideo(media, this.video.currentTime);
+ this.props.onOpenVideo(media, options);
}
handleCloseVideo = () => {