Handle all possible playMedia() in componentDidUpdate()

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-07-29 15:31:25 +02:00
parent 38a1b922bd
commit 871f1b7a5c
No known key found for this signature in database
GPG key ID: 55C211A1226CB17D

View file

@ -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) {
@ -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(),