Skip to content

Commit 8d280b8

Browse files
authored
Merge pull request #272 from Azure-Samples/chwhilar/equal-height-pinned-videos
Chwhilar/equal height pinned videos
2 parents b71ae6b + ccb19da commit 8d280b8

File tree

2 files changed

+48
-11
lines changed

2 files changed

+48
-11
lines changed

Project/src/App.css

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ div.ms-Checkbox>input[type="checkbox"]+label.ms-Checkbox-label>span.ms-Checkbox-
414414
.stream-container.pinned {
415415
order: 0;
416416
flex: 0 100% !important;
417+
text-align: -webkit-center;
417418
}
418419

419420
.stream-container.pinning-is-active {
@@ -474,11 +475,36 @@ div.ms-Checkbox>input[type="checkbox"]+label.ms-Checkbox-label>span.ms-Checkbox-
474475

475476
.remote-video-container {
476477
position: relative;
477-
height: 100%;
478+
}
479+
480+
.remote-video-container.pinning-is-active {
481+
height: 234px !important;
482+
width: 416px !important;
483+
justify-self: center;
484+
}
485+
486+
.remote-video-container.pinned {
487+
height: 720px !important;
488+
width: 1280px !important;
489+
justify-self: center;
490+
}
491+
492+
.remote-video-container.pinned.portrait {
493+
height: 1280px !important;
494+
width: 720px !important;
495+
justify-self: center;
496+
}
497+
498+
@media screen and (max-width: 1024px){
499+
.remote-video-container.pinned, .remote-video-container.pinned.portrait {
500+
height: 100% !important;
501+
width: 100% !important;
502+
justify-self: unset;
503+
}
478504
}
479505

480506
.remote-video-container video {
481-
object-fit: cover !important;
507+
object-fit: contain !important;
482508
object-position: center center;
483509
}
484510

Project/src/MakeCall/StreamRenderer.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ export const StreamRenderer = forwardRef(({
2727
const [displayName, setDisplayName] = useState(remoteParticipant?.displayName?.trim() ?? '');
2828
const [videoStats, setVideoStats] = useState();
2929
const [transportStats, setTransportStats] = useState();
30+
const [height, setHeight] = useState(stream.size.height);
31+
const [width, setWidth] = useState(stream.size.width);
3032

3133
useEffect(() => {
3234
initializeComponent();
3335
return () => {
3436
stream.off('isReceivingChanged', isReceivingChanged);
37+
stream.off('sizeChanged', sizeChanged);
3538
remoteParticipant.off('isSpeakingChanged', isSpeakingChanged);
3639
remoteParticipant.off('isMutedChanged', isMutedChanged);
3740
remoteParticipant.off('displayNameChanged', isDisplayNameChanged);
@@ -94,6 +97,11 @@ export const StreamRenderer = forwardRef(({
9497
}
9598
};
9699

100+
const sizeChanged = () => {
101+
setHeight(stream.size.height);
102+
setWidth(stream.size.width);
103+
}
104+
97105
const isMutedChanged = () => {
98106
setIsMuted(remoteParticipant && remoteParticipant?.isMuted);
99107
};
@@ -110,6 +118,7 @@ export const StreamRenderer = forwardRef(({
110118
*/
111119
const initializeComponent = async () => {
112120
stream.on('isReceivingChanged', isReceivingChanged);
121+
stream.on('sizeChanged', sizeChanged);
113122
remoteParticipant.on('isMutedChanged', isMutedChanged);
114123
remoteParticipant.on('isSpeakingChanged', isSpeakingChanged);
115124
if (dominantSpeakerMode && dominantRemoteParticipant !== remoteParticipant) {
@@ -149,9 +158,11 @@ export const StreamRenderer = forwardRef(({
149158
${stream.mediaStreamType === 'ScreenSharing' ? `ms-xxl12` : ``}
150159
${stream.isAvailable ? 'rendering' : ''}
151160
${isPinned ? 'pinned' : (isPinningActive ? 'pinning-is-active' : '')}`}>
152-
<div className={`remote-video-container ${isSpeaking && !isMuted ? `speaking-border-for-video` : ``}`}
153-
id={videoContainerId}
154-
ref={videoContainer}>
161+
<div id={videoContainerId}
162+
ref={videoContainer}
163+
className={`remote-video-container ${isSpeaking && !isMuted ? `speaking-border-for-video` : ``}
164+
${isPinned ? 'pinned' : (isPinningActive ? 'pinning-is-active' : '')}
165+
${height > width ? 'portrait' : ''}`}>
155166
<h4 className="video-title">
156167
{displayName ? displayName : remoteParticipant.displayName ? remoteParticipant.displayName : utils.getIdentifierText(remoteParticipant.identifier)}
157168
</h4>
@@ -172,13 +183,13 @@ export const StreamRenderer = forwardRef(({
172183
{
173184
isLoading && <div className="remote-video-loading-spinner"></div>
174185
}
186+
{
187+
videoStats && showMediaStats &&
188+
<h4 className="video-stats">
189+
<VideoReceiveStats videoStats={videoStats} transportStats={transportStats} />
190+
</h4>
191+
}
175192
</div>
176-
{
177-
videoStats && showMediaStats &&
178-
<h4 className="video-stats">
179-
<VideoReceiveStats videoStats={videoStats} transportStats={transportStats} />
180-
</h4>
181-
}
182193
</div>
183194
);
184195
}

0 commit comments

Comments
 (0)