@@ -90,6 +90,
8000
7 @@ @implementation FlutterWebRTCPlugin {
90
90
id _messenger;
91
91
id _textures;
92
92
BOOL _speakerOn;
93
+ BOOL _speakerOnButPreferBluetooth;
93
94
AVAudioSessionPort _preferredInput;
94
95
}
95
96
@@ -135,6 +136,7 @@ - (instancetype)initWithChannel:(FlutterMethodChannel*)channel
135
136
_textures = textures;
136
137
_messenger = messenger;
137
138
_speakerOn = NO ;
139
+ _speakerOnButPreferBluetooth = NO ;
138
140
_eventChannel = eventChannel;
139
141
#if TARGET_OS_IPHONE
140
142
_preferredInput = AVAudioSessionPortHeadphones;
@@ -851,6 +853,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
851
853
NSDictionary * argsMap = call.arguments ;
852
854
NSNumber * enable = argsMap[@" enable" ];
853
855
_speakerOn = enable.boolValue ;
856
+ _speakerOnButPreferBluetooth = NO ;
854
857
[AudioUtils setSpeakerphoneOn: _speakerOn];
855
858
result (nil );
856
859
}
@@ -859,6 +862,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
859
862
result (nil );
860
863
}
861
864
else if ([@" enableSpeakerphoneButPreferBluetooth" isEqualToString: call.method]) {
865
+ _speakerOn = YES ;
866
+ _speakerOnButPreferBluetooth = YES ;
862
867
[AudioUtils setSpeakerphoneOnButPreferBluetooth ];
863
868
result (nil );
864
869
}
@@ -1364,7 +1369,11 @@ - (BOOL)hasLocalAudioTrack {
1364
1369
- (void )ensureAudioSession {
1365
1370
#if TARGET_OS_IPHONE
1366
1371
[AudioUtils ensureAudioSessionWithRecording: [self hasLocalAudioTrack ]];
1367
- [AudioUtils setSpeakerphoneOn: _speakerOn];
1372
+ if (_speakerOnButPreferBluetooth) {
1373
+ [AudioUtils setSpeakerphoneOnButPreferBluetooth ];
1374
+ } else {
1375
+ [AudioUtils setSpeakerphoneOn: _speakerOn];
1376
+ }
1368
1377
#endif
1369
1378
}
1370
1379
0 commit comments