Closed Anirudhastikar closed 4 days ago
We have tried with the above code but does not work - audio is coming only in the ear piece - NOT speaker - requirement is to have the audio on speaker. Also we have referred this with no luck - https://github.com/aws-samples/amazon-chime-react-native-demo/issues/5
Any update ?
For Kotlin we tried this and it work by adding it in NativeMobileSDKBridge.m
@ReactMethod
fun setSpeakerOn() {
logger.info(TAG, "Called setSpeakerOn")
// Filter out OTHER type which is currently not supported for selection
val device : MediaDevice ? = meetingSession?.audioVideo?.listAudioDevices()?.find { ad -> ad.type == MediaDeviceType.AUDIO_BUILTIN_SPEAKER }
meetingSession?.audioVideo?.chooseAudioDevice(device!!)
}
and for ios we tried this by adding it in NativeMobileSDKBridge.m
-(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 addRealtimeDataMessageObserverWithTopic:@"chat" observer:observer];
// Enable the speaker
[self startAudioVideo];
[self enableSpeaker];
}
-(void)enableSpeaker
{
// List available audio devices
NSArray<MediaDevice *> *audioDevices = [meetingSession.audioVideo listAudioDevices];
// Log the audio devices
NSLog(@"Available audio devices:");
for (MediaDevice *device in audioDevices) {
NSLog(@"Device: %@", device);
}
// Find and select the speaker device
MediaDevice *speakerDevice = nil;
for (MediaDevice *device in audioDevices) {
if (device.type == MediaDeviceTypeAudioBluetooth) {
NSLog(@"Device inside: %@", device);
speakerDevice = device;
break;
}
if (device.type == MediaDeviceTypeAudioWiredHeadset) {
NSLog(@"Device inside: %@", device);
speakerDevice = device;
break;
}
if (device.type == MediaDeviceTypeAudioBuiltInSpeaker) {
NSLog(@"Device inside: %@", device);
speakerDevice = device;
break;
}
}
if (speakerDevice) {
// Set the speaker device as the active audio device
[meetingSession.audioVideo chooseAudioDeviceWithMediaDevice:speakerDevice];
[logger infoWithMsg:@"Speaker device selected."];
} else {
[logger errorWithMsg:@"No speaker device found."];
}
}
Thanks @Anirudhastikar!
Unable to on the speaker when we are join the call we have referred the issue as reference https://github.com/aws-samples/amazon-chime-react-native-demo/issues/5
this is the bridge code where the audio code is written
and need help on camera switching front and back
amplify version is 12.0.3