Use mic mute icons

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-07-29 15:05:26 +02:00
parent 152168ef2d
commit cb89dd408c
No known key found for this signature in database
GPG key ID: 55C211A1226CB17D
4 changed files with 103 additions and 29 deletions

View file

@ -76,16 +76,22 @@ limitations under the License.
&.mx_VideoFeed_voice { &.mx_VideoFeed_voice {
// We don't want to collide with the call controls that have 52px of height // We don't want to collide with the call controls that have 52px of height
padding-bottom: 52px; margin-bottom: 52px;
background-color: $inverted-bg-color; background-color: $inverted-bg-color;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
&.mx_VideoFeed_video { .mx_VideoFeed_video {
height: 100%;
background-color: #000; background-color: #000;
} }
.mx_VideoFeed_mic {
left: 10px;
bottom: 10px;
}
} }
} }

View file

@ -35,12 +35,23 @@ limitations under the License.
width: 100%; width: 100%;
&.mx_VideoFeed_voice { &.mx_VideoFeed_voice {
border-radius: 4px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
aspect-ratio: 16 / 9; aspect-ratio: 16 / 9;
} }
.mx_VideoFeed_video {
border-radius: 4px;
}
.mx_VideoFeed_mic {
left: 6px;
bottom: 6px;
}
} }
&.mx_CallViewSidebar_pipMode { &.mx_CallViewSidebar_pipMode {

View file

@ -15,18 +15,52 @@ limitations under the License.
*/ */
.mx_VideoFeed { .mx_VideoFeed {
border-radius: 4px; overflow: hidden;
position: relative;
&.mx_VideoFeed_voice { &.mx_VideoFeed_voice {
background-color: $inverted-bg-color; background-color: $inverted-bg-color;
} }
&.mx_VideoFeed_video { .mx_VideoFeed_video {
width: 100%;
background-color: transparent; background-color: transparent;
&.mx_VideoFeed_video_mirror {
transform: scale(-1, 1);
}
}
.mx_VideoFeed_mic {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
background-color: rgba(0, 0, 0, 0.5); // Same on both themes
border-radius: 100%;
&::before {
position: absolute;
content: "";
width: 16px;
height: 16px;
mask-repeat: no-repeat;
mask-size: contain;
mask-position: center;
background-color: white; // Same on both themes
border-radius: 7px;
}
&.mx_VideoFeed_mic_muted::before {
mask-image: url('$(res)/img/voip/mic-muted.svg');
}
&.mx_VideoFeed_mic_unmuted::before {
mask-image: url('$(res)/img/voip/mic-unmuted.svg');
}
} }
} }
.mx_VideoFeed_mirror {
transform: scale(-1, 1);
}

View file

@ -22,7 +22,7 @@ import { CallFeed, CallFeedEvent } from 'matrix-js-sdk/src/webrtc/callFeed';
import { logger } from 'matrix-js-sdk/src/logger'; import { logger } from 'matrix-js-sdk/src/logger';
import MemberAvatar from "../avatars/MemberAvatar"; import MemberAvatar from "../avatars/MemberAvatar";
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import { objectHasDiff } from '../../../utils/objects'; import { SDPStreamMetadataPurpose } from 'matrix-js-sdk/src/webrtc/callEventTypes';
interface IProps { interface IProps {
call: MatrixCall; call: MatrixCall;
@ -165,39 +165,62 @@ export default class VideoFeed extends React.PureComponent<IProps, IState> {
}; };
render() { render() {
const videoClasses = { const { pipMode, primary, feed } = this.props;
mx_VideoFeed: true,
const wrapperClasses = classnames("mx_VideoFeed", {
mx_VideoFeed_voice: this.state.videoMuted, mx_VideoFeed_voice: this.state.videoMuted,
mx_VideoFeed_video: !this.state.videoMuted, });
mx_VideoFeed_mirror: ( const micIconClasses = classnames("mx_VideoFeed_mic", {
this.props.feed.isLocal() && mx_VideoFeed_mic_muted: this.state.audioMuted,
SettingsStore.getValue('VideoView.flipVideoHorizontally') mx_VideoFeed_mic_unmuted: !this.state.audioMuted,
), });
};
const { pipMode, primary } = this.props; let micIcon;
if (
feed.purpose !== SDPStreamMetadataPurpose.Screenshare &&
!pipMode &&
!feed.isLocal()
) {
micIcon = (
<div className={micIconClasses} />
);
}
let content;
if (this.state.videoMuted) { if (this.state.videoMuted) {
const member = this.props.feed.getMember(); const member = this.props.feed.getMember();
let avatarSize; let avatarSize;
if (pipMode && primary) avatarSize = 76; if (pipMode && primary) avatarSize = 76;
else if (pipMode && !primary) avatarSize = 16; else if (pipMode && !primary) avatarSize = 16;
else if (!pipMode && primary) avatarSize = 160; else if (!pipMode && primary) avatarSize = 160;
else; // TBD else; // TBD
return ( content =(
<div className={classnames(videoClasses)}> <MemberAvatar
<MemberAvatar member={member}
member={member} height={avatarSize}
height={avatarSize} width={avatarSize}
width={avatarSize} />
/>
</div>
); );
} else { } else {
return ( const videoClasses = classnames("mx_VideoFeed_video", {
<video className={classnames(videoClasses)} ref={this.setElementRef} /> mx_VideoFeed_video_mirror: (
this.props.feed.isLocal() &&
SettingsStore.getValue('VideoView.flipVideoHorizontally')
),
});
content= (
<video className={videoClasses} ref={this.setElementRef} />
); );
} }
return (
<div className={wrapperClasses}>
{ micIcon }
{ content }
</div>
);
} }
} }