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) {
|
||||
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(),
|
||||
|
|
Loading…
Reference in a new issue