@@ -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 ) {
@@ -126,10 +135,6 @@ export const StreamRenderer = forwardRef(({
126135 }
127136 }
128137
129- const isPortrait = ( ) => {
130- return view . current ?. target ?. offsetHeight > view . current ?. target ?. offsetWidth ;
131- }
132-
133138 useImperativeHandle ( ref , ( ) => ( {
134139 updateReceiveStats ( videoStatsReceived , transportStatsReceived ) {
135140 if ( videoStatsReceived ) {
@@ -157,7 +162,7 @@ export const StreamRenderer = forwardRef(({
157162 ref = { videoContainer }
158163 className = { `remote-video-container ${ isSpeaking && ! isMuted ? `speaking-border-for-video` : `` }
159164 ${ isPinned ? 'pinned' : ( isPinningActive ? 'pinning-is-active' : '' ) }
160- ${ isPortrait ( ) ? 'portrait' : '' } ` } >
165+ ${ height > width ? 'portrait' : '' } ` } >
161166 < h4 className = "video-title" >
162167 { displayName ? displayName : remoteParticipant . displayName ? remoteParticipant . displayName : utils . getIdentifierText ( remoteParticipant . identifier ) }
163168 </ h4 >
0 commit comments