Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Participant list fix #1681

Merged
merged 12 commits into from
Dec 22, 2023
2 changes: 1 addition & 1 deletion packages/hms_room_kit/lib/src/meeting/meeting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ class _MeetingPageState extends State<MeetingPage> {
color: HMSThemeColors.backgroundDim,
child: (isVideoOn && previewForRoleTracks.item1 != null)
? Center(
child: HMSVideoView(
child: HMSTextureView(
scaleType: ScaleType.SCALE_ASPECT_FILL,
track: previewForRoleTracks.item1!,
setMirror: true,
Expand Down
30 changes: 23 additions & 7 deletions packages/hms_room_kit/lib/src/meeting/meeting_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,11 @@ class MeetingStore extends ChangeNotifier
}

void setPreviousRole(String oldRole) {
if (HMSRoomLayout.skipPreviewForRole) {
_hmsSDKInteractor.changeMetadata(
metadata: "{\"isBRBOn\":false,\"prevRole\":\"$oldRole\"}",
hmsActionResultListener: this);
_hmsSDKInteractor.changeMetadata(
metadata: "{\"isBRBOn\":false,\"prevRole\":\"$oldRole\"}",
hmsActionResultListener: this);
if (isRaisedHand) {
toggleLocalPeerHandRaise();
}
}

Expand Down Expand Up @@ -588,14 +589,14 @@ class MeetingStore extends ChangeNotifier
if (indexForVideoTrack != -1) {
previewForRoleVideoTrack =
result[indexForVideoTrack] as HMSLocalVideoTrack;
isVideoOn = true;
isVideoOn = !(previewForRoleVideoTrack?.isMute ?? true);
}
var indexForAudioTrack = result.indexWhere(
(element) => element.kind == HMSTrackKind.kHMSTrackKindAudio);
if (indexForAudioTrack != -1) {
previewForRoleAudioTrack =
result[indexForAudioTrack] as HMSLocalAudioTrack;
isMicOn = true;
isMicOn = !(previewForRoleAudioTrack?.isMute ?? true);
}
notifyListeners();
}
Expand Down Expand Up @@ -729,19 +730,31 @@ class MeetingStore extends ChangeNotifier
}
log("Calling refresh PeerList Method $peerListIterators");
peerListIterators.clear();

///Here we get off stage roles
List<String>? offStageRoles = HMSRoomLayout.roleLayoutData?.screens
?.conferencing?.defaultConf?.elements?.onStageExp?.offStageRoles;

///For each off stage role we get the peer list iterator
offStageRoles?.forEach((role) async {
var peerListIterator = await _hmsSDKInteractor.getPeerListIterator(
peerListIteratorOptions:
PeerListIteratorOptions(limit: 10, byRoleName: role));

///If the peerListIterator is not null then we add it to the map
if (peerListIterator != null && peerListIterator is HMSPeerListIterator) {
peerListIterators[role] = peerListIterator;

///Here we subtract the number of participants in meeting with the number of participants in the iterator
participantsInMeeting -= participantsInMeetingMap[role]?.length ?? 0;
participantsInMeetingMap[role]?.clear();

///Here we get the first set of peers from the iterator
dynamic nonRealTimePeers = await peerListIterator.next();
if (nonRealTimePeers is List<HMSPeer>) {
log("Calling refresh PeerList Method $nonRealTimePeers");
log("Calling refresh PeerList Method here $nonRealTimePeers");

///Here we add the peers to the participantsInMeetingMap
if (nonRealTimePeers.isNotEmpty) {
for (var peer in nonRealTimePeers) {
addPeer(peer);
Expand Down Expand Up @@ -1413,6 +1426,8 @@ class MeetingStore extends ChangeNotifier
notifyListeners();
} else if (peerUpdate == HMSPeerUpdate.metadataChanged) {
participantsInMeetingMap[peer.role.name]?[index].updatePeer(peer);
} else if (peerUpdate == HMSPeerUpdate.metadataChanged) {
participantsInMeetingMap[peer.role.name]?[index].updatePeer(peer);
}
} else {
if (peerUpdate == HMSPeerUpdate.roleUpdated) {
Expand Down Expand Up @@ -1472,6 +1487,7 @@ class MeetingStore extends ChangeNotifier
case HMSPeerUpdate.roleUpdated:
if (peer.isLocal) {
getSpotlightPeer();
setPreviousRole(localPeer?.role.name ?? "");
resetLayout(peer.role.name);
localPeer = peer;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/hms_room_kit/lib/src/preview/preview_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class PreviewStore extends ChangeNotifier
getRoles();
getCurrentAudioDevice();
getAudioDevicesList();
toggleCameraMuteState();
toggleMicMuteState();
notifyListeners();
}

Expand Down
12 changes: 7 additions & 5 deletions packages/hms_room_kit/lib/src/screen_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class _ScreenControllerState extends State<ScreenController> {
}
_hmsSDKInteractor = HMSSDKInteractor(
iOSScreenshareConfig: widget.options?.iOSScreenshareConfig,
joinWithMutedAudio: AppDebugConfig.joinWithMutedAudio,
joinWithMutedVideo: AppDebugConfig.joinWithMutedVideo,
joinWithMutedAudio: true,
joinWithMutedVideo: true,
isSoftwareDecoderDisabled: AppDebugConfig.isSoftwareDecoderDisabled,
isAudioMixerDisabled: AppDebugConfig.isAudioMixerDisabled,
isPrebuilt: true);
Expand All @@ -125,9 +125,11 @@ class _ScreenControllerState extends State<ScreenController> {
});
} else {
_hmsSDKInteractor.toggleAlwaysScreenOn();
setState(() {
isLoading = false;
});
if (mounted) {
setState(() {
isLoading = false;
});
}
Constant.debugMode = AppDebugConfig.isDebugMode;
}
}
Expand Down
4 changes: 0 additions & 4 deletions packages/hms_room_kit/lib/src/service/app_debug_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ class AppDebugConfig {
Setting these values to defaults and can be toggled from the application
This will not be shipped with the ui_kit package and only used for internal testing
*/
static bool joinWithMutedAudio = false;
static bool joinWithMutedVideo = false;
static bool skipPreview = false;
static bool mirrorCamera = true;
static bool showStats = false;
Expand All @@ -24,8 +22,6 @@ class AppDebugConfig {

/// Resets the debug configuration to default values
static void resetToDefault() {
joinWithMutedAudio = true;
joinWithMutedVideo = true;
skipPreview = false;
mirrorCamera = true;
showStats = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
peer: peer,
roleName: onStageRole,
forceChange: HMSRoomLayout.skipPreviewForRole);
meetingStore.setPreviousRole(peer.role.name);
meetingStore.removeToast(HMSToastsType.roleChangeToast,
data: peer);
}
Expand Down Expand Up @@ -338,19 +337,30 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
// child: TextField(),
// ),
// ),
Selector<MeetingStore,
Tuple2<Map<String, List<ParticipantsStore>>, int>>(
selector: (_, meetingStore) => Tuple2(
meetingStore.participantsInMeetingMap,
meetingStore.participantsInMeeting),
builder: (_, data, __) {
return ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: data.item1.keys.length,
itemBuilder: (context, index) {
String role = data.item1.keys.elementAt(index);
return (data.item1[role]?.isNotEmpty ?? false)
ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: context
.read<MeetingStore>()
.participantsInMeetingMap
.keys
.length,
itemBuilder: (context, index) {
String role = context
.read<MeetingStore>()
.participantsInMeetingMap
.keys
.elementAt(index);
return Selector<MeetingStore,
Tuple2<int, List<ParticipantsStore>?>>(
selector: (_, meetingStore) => Tuple2(
meetingStore
.participantsInMeetingMap[role]?.length ??
0,
meetingStore.participantsInMeetingMap[role]),
builder: (_, participantsPerRole, __) {
return (participantsPerRole.item2?.isNotEmpty ??
false)
? Column(
children: [
ClipRRect(
Expand Down Expand Up @@ -379,30 +389,30 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
.onSurfaceHighEmphasis,
title: HMSSubheadingText(
text:
"${data.item1.keys.elementAt(index)} (${(HMSRoomLayout.offStageRoles?.contains(role) ?? false) ? context.read<MeetingStore>().peerListIterators[role]?.totalCount ?? 0 : data.item1[role]?.length}) ",
"${context.read<MeetingStore>().participantsInMeetingMap.keys.elementAt(index)} (${(HMSRoomLayout.offStageRoles?.contains(role) ?? false) ? context.read<MeetingStore>().peerListIterators[role]?.totalCount ?? 0 : participantsPerRole.item1}) ",
textColor: HMSThemeColors
.onSurfaceMediumEmphasis,
letterSpacing: 0.1,
),
children: [
SizedBox(
height: data.item1[role] == null
height: participantsPerRole.item2 ==
null
? 0
: (data.item1[role]!.length) *
: (participantsPerRole.item1) *
54,
child: Center(
child: ListView.builder(
physics:
const NeverScrollableScrollPhysics(),
itemCount: data.item1[role]
?.length ??
0,
itemCount:
participantsPerRole.item1,
itemBuilder:
(context, peerIndex) {
ParticipantsStore
currentPeer =
data.item1[role]![
peerIndex];
participantsPerRole
.item2![peerIndex];
return Padding(
padding:
const EdgeInsets.only(
Expand Down Expand Up @@ -450,7 +460,7 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
__) {
return HMSTitleText(
text:
peerName + ((data.item1[role]![peerIndex].peer.isLocal) ? " (You)" : ""),
peerName + ((participantsPerRole.item2![peerIndex].peer.isLocal) ? " (You)" : ""),
fontSize: 14,
lineHeight: 20,
letterSpacing: 0.1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class _ParticipantsViewAllBottomSheetState
peer: peer,
roleName: onStageRole,
forceChange: HMSRoomLayout.skipPreviewForRole);
meetingStore.setPreviousRole(peer.role.name);
meetingStore.removeToast(HMSToastsType.roleChangeToast,
data: peer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class AppSettingsBottomSheet extends StatefulWidget {
}

class _AppSettingsBottomSheetState extends State<AppSettingsBottomSheet> {
bool joinWithMutedAudio = false;
bool joinWithMutedVideo = false;
bool skipPreview = false;
bool mirrorCamera = true;
bool showStats = false;
Expand Down Expand Up @@ -51,10 +49,6 @@ class _AppSettingsBottomSheetState extends State<AppSettingsBottomSheet> {
if (Platform.isAndroid && versions['android'] == null) {
throw const FormatException("android version not found");
}
joinWithMutedAudio =
await Utilities.getBoolData(key: 'join-with-muted-audio') ?? false;
joinWithMutedVideo =
await Utilities.getBoolData(key: 'join-with-muted-video') ?? false;
skipPreview = await Utilities.getBoolData(key: 'skip-preview') ?? false;
mirrorCamera = await Utilities.getBoolData(key: 'mirror-camera') ?? true;
showStats = await Utilities.getBoolData(key: 'show-stats') ?? false;
Expand Down Expand Up @@ -87,8 +81,6 @@ class _AppSettingsBottomSheetState extends State<AppSettingsBottomSheet> {
AppDebugConfig.isAudioMixerDisabled = isAudioMixerDisabled;
AppDebugConfig.isAutoSimulcast = isAutoSimulcast;
AppDebugConfig.isSoftwareDecoderDisabled = isSoftwareDecoderDisabled;
AppDebugConfig.joinWithMutedAudio = joinWithMutedAudio;
AppDebugConfig.joinWithMutedVideo = joinWithMutedVideo;
AppDebugConfig.mirrorCamera = mirrorCamera;
AppDebugConfig.showStats = showStats;
AppDebugConfig.skipPreview = skipPreview;
Expand Down Expand Up @@ -225,66 +217,6 @@ class _AppSettingsBottomSheetState extends State<AppSettingsBottomSheet> {
setState(() {})
}),
),
ListTile(
horizontalTitleGap: 2,
enabled: false,
contentPadding: EdgeInsets.zero,
leading: SvgPicture.asset(
"packages/hms_room_kit/lib/src/assets/icons/mic_state_off.svg",
fit: BoxFit.scaleDown,
colorFilter:
ColorFilter.mode(themeDefaultColor, BlendMode.srcIn),
),
title: Text(
"Join with muted audio",
semanticsLabel: "fl_join_with_muted_audio",
style: HMSTextStyle.setTextStyle(
fontSize: 14,
color: themeDefaultColor,
letterSpacing: 0.25,
fontWeight: FontWeight.w600),
),
trailing: CupertinoSwitch(
activeColor: hmsdefaultColor,
value: joinWithMutedAudio,
onChanged: (value) => {
joinWithMutedAudio = value,
Utilities.saveBoolData(
key: 'join-with-muted-audio', value: value),
AppDebugConfig.joinWithMutedAudio = value,
setState(() {})
}),
),
ListTile(
horizontalTitleGap: 2,
enabled: false,
contentPadding: EdgeInsets.zero,
leading: SvgPicture.asset(
"packages/hms_room_kit/lib/src/assets/icons/cam_state_off.svg",
fit: BoxFit.scaleDown,
colorFilter:
ColorFilter.mode(themeDefaultColor, BlendMode.srcIn),
),
title: Text(
"Join with muted video",
semanticsLabel: "fl_join_with_muted_video",
style: HMSTextStyle.setTextStyle(
fontSize: 14,
color: themeDefaultColor,
letterSpacing: 0.25,
fontWeight: FontWeight.w600),
),
trailing: CupertinoSwitch(
activeColor: hmsdefaultColor,
value: joinWithMutedVideo,
onChanged: (value) => {
joinWithMutedVideo = value,
Utilities.saveBoolData(
key: 'join-with-muted-video', value: value),
AppDebugConfig.joinWithMutedVideo = value,
setState(() {})
}),
),
// ListTile(
// horizontalTitleGap: 2,
// enabled: false,
Expand Down
2 changes: 2 additions & 0 deletions packages/hmssdk_flutter/example/lib/qr_code_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class _QRCodeScreenState extends State<QRCodeScreen> {
} else {
Constant.roomCode = scanData.code!.trim();
}
Utilities.saveStringData(
key: "meetingLink", value: scanData.code!.trim());
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (_) => HMSPrebuilt(
roomCode: Constant.roomCode,
Expand Down