From 871f1b7a5c1c64dc8b465b2d183dcce1d3ecbdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 29 Jul 2021 15:31:25 +0200 Subject: [PATCH] Handle all possible playMedia() in componentDidUpdate() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/voip/VideoFeed.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/views/voip/VideoFeed.tsx b/src/components/views/voip/VideoFeed.tsx index 0d0e874f039..bff4559a6e2 100644 --- a/src/components/views/voip/VideoFeed.tsx +++ b/src/components/views/voip/VideoFeed.tsx @@ -72,7 +72,12 @@ export default class VideoFeed extends React.PureComponent { componentDidUpdate(prevProps: IProps, prevState: IState) { this.updateFeed(prevProps.feed, this.props.feed); // 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) { @@ -143,15 +148,14 @@ export default class VideoFeed extends React.PureComponent { // seem to be necessary - Šimon } - private onNewStream = async () => { - await this.setState({ + private onNewStream = () => { + this.setState({ audioMuted: this.props.feed.isAudioMuted(), videoMuted: this.props.feed.isVideoMuted(), }); - this.playMedia(); }; - private onMuteStateChanged = async () => { + private onMuteStateChanged = () => { this.setState({ audioMuted: this.props.feed.isAudioMuted(), videoMuted: this.props.feed.isVideoMuted(),