8000 Supports ensureAudioSsession method for iOS only. (#1514) · baihua666/flutter-webrtc@7cdb53a · GitHub
[go: up one dir, main page]

Skip to content

Commit 7cdb53a

Browse files
Supports ensureAudioSsession method for iOS only. (flutter-webrtc#1514)
* Supports audio session method for iOS only. Sometimes this needs to be called manually when changing the audioSession configuration with a 3rd party plugin. * check format
1 parent 0a5bc58 commit 7cdb53a

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

common/darwin/Classes/FlutterWebRTCPlugin.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,10 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
856856
[AudioUtils setSpeakerphoneOn:_speakerOn];
857857
result(nil);
858858
}
859+
else if ([@"ensureAudioSession" isEqualToString:call.method]) {
860+
[self ensureAudioSession];
861+
result(nil);
862+
}
859863
else if ([@"enableSpeakerphoneButPreferBluetooth" isEqualToString:call.method]) {
860864
[AudioUtils setSpeakerphoneOnButPreferBluetooth];
861865
result(nil);

lib/src/helper.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ class Helper {
105105
static Future<void> setSpeakerphoneOn(bool enable) =>
106106
NativeAudioManagement.setSpeakerphoneOn(enable);
107107

108+
/// Ensure audio session
109+
/// for iOS only
110+
static Future<void> ensureAudioSession() =>
111+
NativeAudioManagement.ensureAudioSession();
112+
108113
/// Enable speakerphone, but use bluetooth if audio output device available
109114
/// for iOS/Android only
110115
static Future<void> setSpeakerphoneOnButPreferBluetooth() =>

lib/src/native/audio_management.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class NativeAudioManagement {
2121
);
2222
}
2323

24+
static Future<void> ensureAudioSession() async {
25+
await WebRTC.invokeMethod('ensureAudioSession');
26+
}
27+
2428
static Future<void> setSpeakerphoneOnButPreferBluetooth() async {
2529
await WebRTC.invokeMethod('enableSpeakerphoneButPreferBluetooth');
2630
}

0 commit comments

Comments
 (0)
0