Skip to content

Commit 58bcebc

Browse files
authored
Tweaks (#27)
* Add mute icon to name bar and fix bg bug * Hide peer sidepane when presenting on smaller displays * Ensure camera is turned off when done
1 parent 8cb78aa commit 58bcebc

File tree

4 files changed

+60
-15
lines changed

4 files changed

+60
-15
lines changed

src/arCubePlugin.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,16 @@ class ArCubePlugin implements HMSVideoPlugin {
162162

163163
stop() {
164164
// Remove video element added by AR.js
165-
const el = document.getElementById('arjs-video');
166-
el?.remove();
165+
const video = document.getElementById('arjs-video') as HTMLVideoElement;
166+
167+
if (video) {
168+
for (const track of (video.srcObject as MediaStream).getTracks()) {
169+
track.stop();
170+
}
171+
video.srcObject = null;
172+
173+
video.remove();
174+
}
167175
}
168176
}
169177

src/components/Peer.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
selectDominantSpeaker,
55
selectIsPeerVideoEnabled,
66
selectVideoTrackByPeerID,
7+
useAVToggle,
78
useHMSStore,
89
useVideo
910
} from '@100mslive/react-sdk';
@@ -13,7 +14,11 @@ import {
1314
faFaceSmileBeam,
1415
faFaceTired
1516
} from '@fortawesome/free-regular-svg-icons';
16-
import { faHand } from '@fortawesome/free-solid-svg-icons';
17+
import {
18+
faHand,
19+
faMicrophone,
20+
faMicrophoneSlash
21+
} from '@fortawesome/free-solid-svg-icons';
1722
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
1823
import React from 'react';
1924
import Avatar from './Avatar';
@@ -34,6 +39,7 @@ const Peer = ({ peer, location, height, width }: IPeer) => {
3439
});
3540
const videoTrack = useHMSStore(selectVideoTrackByPeerID(peer.id));
3641
const isPeerVideoEnabled = useHMSStore(selectIsPeerVideoEnabled(peer.id));
42+
const { isLocalAudioEnabled } = useAVToggle();
3743

3844
const dominantSpeaker = useHMSStore(selectDominantSpeaker);
3945
const downlinkQuality = useHMSStore(
@@ -94,6 +100,7 @@ const Peer = ({ peer, location, height, width }: IPeer) => {
94100
className={`jlab-gather-peer-tile jlab-gather-peer-tile-${location}
95101
${peer.isHandRaised ? 'jlab-gather-peer-hand-raised' : ''}
96102
${peer.id === dominantSpeaker?.id ? 'jlab-gather-active-speaker' : ''}
103+
${!isPeerVideoEnabled ? 'jlab-gather-peer-tile-grid-bg' : ''}
97104
`}
98105
style={{ height: height, width: width }}
99106
>
@@ -111,14 +118,28 @@ const Peer = ({ peer, location, height, width }: IPeer) => {
111118
<video
112119
ref={videoRef}
113120
className={`jlab-gather-peer-video jlab-gather-peer-video-${location}
114-
${peer.isLocal ? 'jlab-gather-local' : ''}
115-
116-
`}
121+
${peer.isLocal ? 'jlab-gather-local' : ''}`}
117122
autoPlay
118123
muted
119124
playsInline
120125
/>
121-
<div className="jlab-gather-peer-name">{peer.name}</div>
126+
{location !== 'presenter' && (
127+
<div className="jlab-gather-peer-name">
128+
{isLocalAudioEnabled ? (
129+
<FontAwesomeIcon
130+
icon={faMicrophone}
131+
className="jlab-gather-icon-small"
132+
/>
133+
) : (
134+
<FontAwesomeIcon
135+
icon={faMicrophoneSlash}
136+
className="jlab-gather-icon-small"
137+
/>
138+
)}
139+
{' '}
140+
{peer.name}
141+
</div>
142+
)}
122143
</>
123144
) : (
124145
<Avatar

src/layouts/PresenterView.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import React, { useEffect } from 'react';
77
import Peer from '../components/Peer';
88
import PeerSidePane from '../components/PeerSidePane';
99
import {
10+
ASPECT_RATIO_BREAKPOINT,
1011
SESSION_STORE,
1112
SIDEPANE_PEER_LIST_MARGIN,
1213
SIDEPANE_PEER_LIST_PADDING,
1314
SIDEPANE_PEER_LIST_TILE,
1415
TILE_HORIZONTAL_MARGIN,
16+
TILE_VIEW_GRID_HORIZONTAL_MARGIN,
1517
TILE_VIEW_GRID_VERTICAL_MARGIN
1618
} from '../constants';
1719
import { useResizeObserver } from '../hooks/useResizeObserver';
@@ -21,11 +23,14 @@ const PresenterView = () => {
2123
const presenter = useHMSStore(selectSessionStore(SESSION_STORE.presenterId));
2224
const rootDimensions = useResizeObserver();
2325

24-
const sidepaneWidth =
25-
SIDEPANE_PEER_LIST_TILE +
26-
SIDEPANE_PEER_LIST_PADDING * 2 +
27-
SIDEPANE_PEER_LIST_MARGIN +
28-
TILE_HORIZONTAL_MARGIN;
26+
const widthToUse =
27+
rootDimensions.width >= ASPECT_RATIO_BREAKPOINT
28+
? rootDimensions.width -
29+
SIDEPANE_PEER_LIST_TILE +
30+
SIDEPANE_PEER_LIST_PADDING * 2 +
31+
SIDEPANE_PEER_LIST_MARGIN +
32+
TILE_HORIZONTAL_MARGIN
33+
: rootDimensions.width - TILE_VIEW_GRID_HORIZONTAL_MARGIN;
2934

3035
useEffect(() => {
3136
const controlBar = document.getElementById('jlab-gather-control-bar');
@@ -43,12 +48,14 @@ const PresenterView = () => {
4348
location="presenter"
4449
peer={presenter}
4550
height={rootDimensions.height - TILE_VIEW_GRID_VERTICAL_MARGIN}
46-
width={rootDimensions.width - sidepaneWidth}
51+
width={widthToUse}
4752
/>
4853
) : (
4954
<div>Waiting...</div>
5055
)}
51-
<PeerSidePane peers={peers} />
56+
{rootDimensions.width > ASPECT_RATIO_BREAKPOINT ? (
57+
<PeerSidePane peers={peers} />
58+
) : null}
5259
</div>
5360
);
5461
};

style/base.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
.jlab-gather-peer-tile-grid {
115115
align-items: center;
116116
flex-grow: 1;
117+
position: relative;
118+
}
119+
120+
.jlab-gather-peer-tile-grid.jlab-gather-peer-tile-grid-bg {
117121
background-color: var(--gather-speaker-bg);
118122
}
119123

@@ -310,6 +314,11 @@
310314
font-size: 2rem;
311315
}
312316

317+
.jlab-gather-icon-small {
318+
width: 15px;
319+
font-size: 0.75rem;
320+
}
321+
313322
.jlab-gather-icon-breathe {
314323
animation: breathe 3s infinite alternate;
315324
color: #f37726;
@@ -366,7 +375,7 @@
366375
}
367376

368377
.jlab-gather-avatar-grid {
369-
height: 60%;
378+
/* height: 60%; */
370379
}
371380

372381
.jlab-gather-avatar-sidepane {

0 commit comments

Comments
 (0)