8000 Add speakerphone support for iOS · selinplus/flutter-webrtc@2e7dcc1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2e7dcc1

Browse files
committed
Add speakerphone support for iOS
1 parent 571594a commit 2e7dcc1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ios/Classes/FlutterWebRTCPlugin.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,15 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult) result
388388
audioTrack.isEnabled = !mute.boolValue;
389389
}
390390
result(nil);
391+
} else if ([@"enableSpeakerphone" isEqualToString:call.method]) {
392+
NSDictionary* argsMap = call.arguments;
393+
NSNumber* enable = argsMap[@"enable"];
394+
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
395+
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord
396+
withOptions:enable.boolValue ? AVAudioSessionCategoryOptionDefaultToSpeaker : 0
397+
error:nil];
398+
[audioSession setActive:YES error:nil];
399+
result(nil);
391400
}else if ([@"getLocalDescription" isEqualToString:call.method]) {
392401
NSDictionary* argsMap = call.arguments;
393402
NSString* peerConnectionId = argsMap[@"peerConnectionId"];

0 commit comments

Comments
 (0)
0