2017-05-03 10:04:16 +10:00
|
|
|
import React from 'react';
|
2017-04-22 04:05:35 +10:00
|
|
|
import PropTypes from 'prop-types';
|
2017-03-05 08:17:10 +11:00
|
|
|
|
2017-06-24 03:36:54 +10:00
|
|
|
export default class ExtendedVideoPlayer extends React.PureComponent {
|
2017-03-05 08:17:10 +11:00
|
|
|
|
2017-05-12 22:44:10 +10:00
|
|
|
static propTypes = {
|
|
|
|
src: PropTypes.string.isRequired,
|
2017-07-14 06:18:18 +10:00
|
|
|
width: PropTypes.number,
|
|
|
|
height: PropTypes.number,
|
2017-05-12 22:44:10 +10:00
|
|
|
time: PropTypes.number,
|
|
|
|
controls: PropTypes.bool.isRequired,
|
2017-05-21 01:31:47 +10:00
|
|
|
muted: PropTypes.bool.isRequired,
|
2017-05-12 22:44:10 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
handleLoadedData = () => {
|
2017-04-14 01:01:09 +10:00
|
|
|
if (this.props.time) {
|
|
|
|
this.video.currentTime = this.props.time;
|
|
|
|
}
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
2017-04-14 01:01:09 +10:00
|
|
|
|
|
|
|
componentDidMount () {
|
|
|
|
this.video.addEventListener('loadeddata', this.handleLoadedData);
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
2017-04-14 01:01:09 +10:00
|
|
|
|
|
|
|
componentWillUnmount () {
|
|
|
|
this.video.removeEventListener('loadeddata', this.handleLoadedData);
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
2017-04-14 01:01:09 +10:00
|
|
|
|
2017-05-12 22:44:10 +10:00
|
|
|
setRef = (c) => {
|
2017-04-14 01:01:09 +10:00
|
|
|
this.video = c;
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
2017-04-14 01:01:09 +10:00
|
|
|
|
2017-03-05 08:17:10 +11:00
|
|
|
render () {
|
|
|
|
return (
|
2017-07-18 03:05:29 +10:00
|
|
|
<div className='extended-video-player'>
|
2017-04-14 01:01:09 +10:00
|
|
|
<video
|
|
|
|
ref={this.setRef}
|
|
|
|
src={this.props.src}
|
|
|
|
autoPlay
|
|
|
|
muted={this.props.muted}
|
|
|
|
controls={this.props.controls}
|
|
|
|
loop={!this.props.controls}
|
|
|
|
/>
|
2017-03-05 08:17:10 +11:00
|
|
|
</div>
|
|
|
|
);
|
2017-04-22 04:05:35 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|