Handle all possible playMedia() in componentDidUpdate()
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
38a1b922bd
commit
871f1b7a5c
1 changed files with 9 additions and 5 deletions
|
@ -72,7 +72,12 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
|
||||||
componentDidUpdate(prevProps: IProps, prevState: IState) {
|
componentDidUpdate(prevProps: IProps, prevState: IState) {
|
||||||
this.updateFeed(prevProps.feed, this.props.feed);
|
this.updateFeed(prevProps.feed, this.props.feed);
|
||||||
// If the mutes state has changed, we try to playMedia()
|
// If the mutes state has changed, we try to playMedia()
|
||||||
if (prevState.videoMuted !== this.state.videoMuted) this.playMedia();
|
if (
|
||||||
|
prevState.videoMuted !== this.state.videoMuted ||
|
||||||
|
prevProps.feed.stream !== this.props.feed.stream
|
||||||
|
) {
|
||||||
|
this.playMedia();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDerivedStateFromProps(props: IProps) {
|
static getDerivedStateFromProps(props: IProps) {
|
||||||
|
@ -143,15 +148,14 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
|
||||||
// seem to be necessary - Šimon
|
// seem to be necessary - Šimon
|
||||||
}
|
}
|
||||||
|
|
||||||
private onNewStream = async () => {
|
private onNewStream = () => {
|
||||||
await this.setState({
|
this.setState({
|
||||||
audioMuted: this.props.feed.isAudioMuted(),
|
audioMuted: this.props.feed.isAudioMuted(),
|
||||||
videoMuted: this.props.feed.isVideoMuted(),
|
videoMuted: this.props.feed.isVideoMuted(),
|
||||||
});
|
});
|
||||||
this.playMedia();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private onMuteStateChanged = async () => {
|
private onMuteStateChanged = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
audioMuted: this.props.feed.isAudioMuted(),
|
audioMuted: this.props.feed.isAudioMuted(),
|
||||||
videoMuted: this.props.feed.isVideoMuted(),
|
videoMuted: this.props.feed.isVideoMuted(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue