Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Handle all possible playMedia() in componentDidUpdate()
Browse files Browse the repository at this point in the history
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
  • Loading branch information
SimonBrandner committed Jul 29, 2021
1 parent 38a1b92 commit 871f1b7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/views/voip/VideoFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
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) {
Expand Down Expand Up @@ -143,15 +148,14 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
// 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(),
Expand Down

0 comments on commit 871f1b7

Please sign in to comment.