videoComponent attached to state

This commit is contained in:
NikolaBorislavovHristov 2018-11-07 16:51:05 +02:00
parent e346703d4b
commit ef3fd37ac9
2 changed files with 9 additions and 11 deletions

View file

@ -11,15 +11,14 @@ class Player extends Component {
volume: null,
duration: null,
paused: null,
prepared: false
videoComponent: null
};
}
componentDidMount() {
this.prepareStream()
.then(({ source, component }) => {
this.VideoComponent = component;
this.setState({ prepared: true }, () => {
.then(({ source, videoComponent }) => {
this.setState({ videoComponent }, () => {
this.video.dispatch('command', 'load', {
source: source
});
@ -35,7 +34,7 @@ class Player extends Component {
nextState.volume !== this.state.volume ||
nextState.duration !== this.state.duration ||
nextState.paused !== this.state.paused ||
nextState.prepared !== this.state.prepared;
nextState.videoComponent !== this.state.videoComponent;
}
assignVideo = (video) => {
@ -45,7 +44,7 @@ class Player extends Component {
prepareStream = () => {
return Promise.resolve({
source: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
component: ReactHTMLVideo
videoComponent: ReactHTMLVideo
});
}
@ -66,14 +65,14 @@ class Player extends Component {
}
renderVideo() {
if (!this.state.prepared) {
if (this.state.videoComponent === null) {
return null;
}
return (
<this.VideoComponent
<this.state.videoComponent
ref={this.assignVideo}
className={styles['video-layer']}
className={styles['layer']}
onPropChanged={this.onPropChanged}
onPropValue={this.onPropValue}
onEnded={this.onEnded}

View file

@ -4,11 +4,10 @@
height: 100%;
overflow: hidden;
.video-layer {
.layer {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
}