8000 add support for lightning microphone by cr0manty · Pull Request #693 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content

add support for lightning microphone #693

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

Merged
merged 1 commit into from
Sep 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion common/darwin/Classes/FlutterWebRTCPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ - (instancetype)initWithChannel:(FlutterMethodChannel *)channel
self.localTracks = [NSMutableDictionary new];
self.renders = [[NSMutableDictionary alloc] init];
#if TARGET_OS_IPHONE
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didSessionRouteChange:) name:AVAudioSessionRouteChangeNotification object:nil];
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryMultiRoute withOptions: AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers error:nil];
[session setActive:YES withOptions:kAudioSessionSetActiveFlag_NotifyOthersOnDeactivation error:nil];

[session setActive:YES error:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didSessionRouteChange:) name:AVAudioSessionRouteChangeNotification object:session];
#endif
return self;
}
Expand All @@ -88,6 +94,16 @@ - (void)didSessionRouteChange:(NSNotification *)notification {

switch (routeChangeReason) {
case AVAudioSessionRouteChangeReasonCategoryChange: {
AVAudioSession *session = [AVAudioSession sharedInstance];
if ([session category] != AVAudioSessionCategoryMultiRoute) {
NSError* setCategoryError;
[session setCategory:AVAudioSessionCategoryMultiRoute withOptions: AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers
error:&setCategoryError];
if(setCategoryError != nil) {
NSLog(@"setCategoryError: %@", setCategoryError);
}
}

NSError* error;
[[AVAudioSession sharedInstance] overrideOutputAudioPort:_speakerOn? AVAudioSessionPortOverrideSpeaker : AVAudioSessionPortOverrideNone error:&error];
}
Expand Down
0