Closed ashirkhanpm closed 2 years ago
Hi @ashirkhanpm Thank you for report this and your interest in Amazon Chime mobile SDK.
You can use chooseAudioDevice and listAudioDevices to do this (Android iOS). You will also have to update the bridge and observer so that you can call these from React Native (Android iOS). In this demo, we provide some basic examples of bridging, you can bring in more bridge function by referring these examples.
You can use https://github.com/aws-samples/amazon-chime-react-native-demo/pull/93 as a reference as well.
Hi, @ziyiz-amzn thanks for your replay, and I already tried with the chooseAudioDevice and listAudioDevices, but IOS app getting crashed when trying
RCT_EXPORT_METHOD(switchToEarPice) { NSArray<MediaDevice *> *AudioDevices=[meetingSession.audioVideo listAudioDevices]; NSString *dictionaryKey = @"type"; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K MATCHES %@",dictionaryKey,MediaDeviceTypeAudioHandset]; NSArray *results= [AudioDevices filteredArrayUsingPredicate:predicate]; [meetingSession.audioVideo chooseAudioDeviceWithMediaDevice:results[0]]; NSLog(@"test-Audio-list earpice %@",results ); }
this is my code, is this the right way? or How can I filter one audio device from the available AudioDevices list with type
I think it is the correct approach. You will need to debug the result you get from meetingSession.audioVideo.listAudioDevices()
and then see if the filter you implement works. Any error reported before the crash?
@ziyiz-amzn thanks for your replay
I think the issue in the filtering line
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K MATCHES %@",dictionaryKey,MediaDeviceTypeAudioHandset];
I got this error ["Thread 7: EXC_BAD_ACCESS (code=1, address=0x3)"] when I call the switchToEarPice method at line no 3
does it work without the filter? is it contains the list of all devices ?
@ziyiz-amzn yes, it work without filter, I think the AudioDevices array contains all devices because I can able to print AudioDevices[0] and AudioDevices[1] separately in NSLog
Then you may need to debug your filters.
Hi, How can I switch to the specific audio device [bluetooth/earpiece/speaker/headset], when using the demo app , found something similar on #93 , but it's only connecting to a recently connected device