8000 add support for lightning microphone (#693) · flutter-robert/flutter-webrtc@ee6ee59 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee6ee59

Browse files
cr0mantycr0manty
and
cr0manty
authored
add support for lightning microphone (flutter-webrtc#693)
Co-authored-by: cr0manty <denis.dudka@dataart.com>
1 parent 79cbd5f commit ee6ee59

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

common/darwin/Classes/FlutterWebRTCPlugin.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ - (instancetype)initWithChannel:(FlutterMethodChannel *)channel
7575
self.localTracks = [NSMutableDictionary new];
7676
self.renders = [[NSMutableDictionary alloc] init];
7777
#if TARGET_OS_IPHONE
78-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didSessionRouteChange:) name:AVAudioSessionRouteChangeNotification object:nil];
78+
AVAudioSession *session = [AVAudioSession sharedInstance];
79+
[session setCategory:AVAudioSessionCategoryMultiRoute withOptions: AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers error:nil];
80+
[session setActive:YES withOptions:kAudioSessionSetActiveFlag_NotifyOthersOnDeactivation error:nil];
81+
82+
[session setActive:YES error:nil];
83+
84+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didSessionRouteChange:) name:AVAudioSessionRouteChangeNotification object:session];
7985
#endif
8086
return self;
8187
}
@@ -88,6 +94,16 @@ - (void)didSessionRouteChange:(NSNotification *)notification {
8894

8995
switch (routeChangeReason) {
9096
case AVAudioSessionRouteChangeReasonCategoryChange: {
97+
AVAudioSession *session = [AVAudioSession sharedInstance];
98+
if ([session category] != AVAudioSessionCategoryMultiRoute) {
99+
NSError* setCategoryError;
100+
[session setCategory:AVAudioSessionCategoryMultiRoute withOptions: AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers
101+
error:&setCategoryError];
102+
if(setCategoryError != nil) {
103+
NSLog(@"setCategoryError: %@", setCategoryError);
104+
}
105+
}
106+
91107
NSError* error;
92108
[[AVAudioSession sharedInstance] overrideOutputAudioPort:_speakerOn? AVAudioSessionPortOverrideSpeaker : AVAudioSessionPortOverrideNone error:&error];
93109
}

0 commit comments

Comments
 (0)
0