{this.state.streamUrl && }
)
}
}
export class VideoWrapper extends React.Component {
constructor(props) {
super(props);
this.state = {
video: null,
prev: null,
next: null,
channel: null,
no_channel: null,
}
}
async componentDidMount() {
await this.fetchVideo();
}
async fetchVideo() {
// Get and display the Video specified in the Router match
let [video, prev, next] = await getVideo(this.props.match.params.video_id);
let channel_link = this.props.match.params.channel_link;
let channel = channel_link ? await getChannel(channel_link) : null;
let no_channel = false;
if (!channel) {
no_channel = true;
}
this.setState({video, prev, next, channel, no_channel}, scrollToTop);
}
async componentDidUpdate(prevProps, prevState) {
if (prevProps.match.params.video_id !== this.props.match.params.video_id) {
// Clear the current video so that it will change, even if the video is playing.
this.setState({video: null, prev: null, next: null, channel: null});
await this.fetchVideo();
}
}
render() {
if (this.state.video && (this.state.no_channel || this.state.channel)) {
return