Skip to content

Commit 9ffac3b

Browse files
authored
fix: fixed screensharing persistence and track issue (#681)
* fixed screensharing persistence and track issue * changes keys for rebuilds
1 parent 4230b20 commit 9ffac3b

File tree

4 files changed

+6
-20
lines changed

4 files changed

+6
-20
lines changed

packages/stream_video_flutter/lib/src/call_participants/call_participants.dart

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,8 @@ class _StreamCallParticipantsState extends State<StreamCallParticipants> {
132132
final screenShareTrack = it.screenShareTrack;
133133
final isScreenShareEnabled = it.isScreenShareEnabled;
134134

135-
// If the screen share track is local, we don't have to subscribe to
136-
// anything and we can directly use the mute state.
137-
if (screenShareTrack is! RemoteTrackState) return isScreenShareEnabled;
138-
139-
// If the screen share track is remote and already subscribed and
140-
// received, we can directly use the mute state.
141-
if (screenShareTrack.subscribed && screenShareTrack.received) {
142-
return isScreenShareEnabled;
143-
}
144-
145-
// If it's not yet subscribed, we have to show it in order for it to
146-
// start the subscription process.
135+
if (screenShareTrack == null || !isScreenShareEnabled) return false;
136+
147137
return true;
148138
},
149139
);

packages/stream_video_flutter/lib/src/call_participants/regular_call_participants_content.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ class RegularCallParticipantsContent extends StatelessWidget {
4343
CallParticipantState participant,
4444
) {
4545
return StreamCallParticipant(
46-
// We use the sessionId as the key to avoid rebuilding the widget
47-
// when the participant changes.
48-
key: ValueKey(participant.sessionId),
46+
key: ValueKey(participant.userId),
4947
call: call,
5048
participant: participant,
5149
);

packages/stream_video_flutter/lib/src/call_participants/screen_share_call_participants_content.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ class ScreenShareCallParticipantsContent extends StatelessWidget {
3838
CallParticipantState participant,
3939
) {
4040
return StreamCallParticipant(
41-
// We use the sessionId as the key to avoid rebuilding the widget
42-
// when the participant changes.
43-
key: ValueKey(participant.sessionId),
41+
key: ValueKey(participant.userId),
4442
call: call,
4543
participant: participant,
4644
);
@@ -67,7 +65,7 @@ class ScreenShareCallParticipantsContent extends StatelessWidget {
6765
return Stack(
6866
children: [
6967
ScreenShareContent(
70-
key: ValueKey('${participant.sessionId} - screenShareContent'),
68+
key: ValueKey('${participant.userId} - screenShareContent'),
7169
call: call,
7270
participant: participant,
7371
),

packages/stream_video_flutter/lib/src/renderer/video_renderer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class StreamVideoRenderer extends StatelessWidget {
5858
}
5959

6060
return VisibilityDetector(
61-
key: Key('${participant.sessionId}${trackState?.muted}'),
61+
key: Key('${participant.userId}${participant.sessionId}$videoTrackType${trackState?.muted}'),
6262
onVisibilityChanged: _onVisibilityChanged,
6363
child: child,
6464
);

0 commit comments

Comments
 (0)