aws-samples / amazon-chime-react-native-demo

A React Native demo application for Android and iOS using the Amazon Chime SDK.
MIT No Attribution
101 stars 24 forks source link

Active speaker implementation issue with iOS react native app #122

Closed nborkhataria closed 2 years ago

nborkhataria commented 2 years ago

Cloned the react native chime sdk demo. Need to implement active speaker logic on iOS react native app. Have done below changes for iOS but build is failing with "No known instance method for selector 'addActiveSpeakerObserverWithObserver' ".

Please guide what step I am missing with registering ActiveSpeakerObserver.

MeetingObserver.h :
#define kEventOnActiveSpeaker @"OnActiveSpeaker"
@interface MeetingObservers : NSObject <RealtimeObserver, VideoTileObserver, AudioVideoObserver, ActiveSpeakerObserver>
MeetingObservers.m:
- (void)activeSpeakerDidDetectWithAttendeeInfo:(NSArray<AttendeeInfo *> * _Nonnull)attendeeInfo {
  for (id currentAttendeeInfo in attendeeInfo) {
    [_bridge sendEventWithName:kEventOnActiveSpeaker body:@{@"attendeeId":[currentAttendeeInfo attendeeId], @"externalUserId":[currentAttendeeInfo externalUserId]}];
    [_logger infoWithMsg:[NSString stringWithFormat:@"Attendee %@ join", [currentAttendeeInfo externalUserId]]];
  }
}
NativeMobileSDKBridge.m :
- (NSArray<NSString *> *)supportedEvents
{ .... 
kEventOnActiveSpeaker,
.....}

-(void)startAudioClient
{
  if (meetingSession == nil)
  {
    [logger errorWithMsg:@"meetingSession is not initialized"];
    return;
  }
  MeetingObservers* observer = [[MeetingObservers alloc] initWithBridge:self logger:logger];
  [meetingSession.audioVideo addRealtimeObserverWithObserver:observer];
  [meetingSession.audioVideo addVideoTileObserverWithObserver:observer];
  [meetingSession.audioVideo addAudioVideoObserverWithObserver:observer];
  [meetingSession.audioVideo addActiveSpeakerObserverWithObserver:observer];  (Added line)
  [self startAudioVideo];
}
Bridge.ts :
export const MobileSDKEvent = {
  OnMeetingStart: 'OnMeetingStart',
  OnMeetingEnd: 'OnMeetingEnd',
  OnActiveSpeaker: 'OnActiveSpeaker', (Added line)

IOS: 15.0 react-native: 0.64.0

alnlau commented 2 years ago

Hello,

For adding an ActiveSpeakerObserver, you'll also need to add a ActiveSpeakerPolicy. See here and here for additional details. Also, you'll have to call addActiveSpeakerObserverWithPolicy instead of addActiveSpeakerObserverWithObserver as that is what's in AmazonChimeSDK-Swift.h. Let us know if you have further questions.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.