Skip to content

Commit

Permalink
feat(android): Add manageBluetoothAudio option
Browse files Browse the repository at this point in the history
  • Loading branch information
llfbandit authored Oct 9, 2024
2 parents 4de2b2e + 6f9b361 commit e60d459
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class MethodCallHandlerImpl(
Utils.firstNonNull(call.argument("noiseSuppress"), false),
Utils.firstNonNull(androidConfig?.get("useLegacy") as Boolean?, false),
Utils.firstNonNull(androidConfig?.get("muteAudio") as Boolean?, false),
Utils.firstNonNull(androidConfig?.get("manageBluetoothAudio") as Boolean?, true),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ internal class RecorderWrapper(
}

private fun createRecorder(config: RecordConfig): IRecorder {
maybeStartBluetooth(config)
if (config.manageBluetoothAudio) {
maybeStartBluetooth(config)
}

if (config.useLegacy) {
return MediaRecorder(context, recorderStateStreamHandler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class RecordConfig(
val noiseSuppress: Boolean = false,
val useLegacy: Boolean = false,
val muteAudio: Boolean = false,
val manageBluetoothAudio: Boolean = true,
) {
val numChannels: Int = 2.coerceAtMost(1.coerceAtLeast(numChannels))
}
Expand Down
6 changes: 6 additions & 0 deletions record_platform_interface/lib/src/types/record_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,21 @@ class AndroidRecordConfig {
/// Use at your own risks!
final bool muteAudio;

/// Try to start a bluetooth audio connection to a headset.
/// Defaults to [true].
final bool manageBluetoothAudio;

const AndroidRecordConfig({
this.useLegacy = false,
this.muteAudio = false,
this.manageBluetoothAudio = true,
});

Map<String, dynamic> toMap() {
return {
'useLegacy': useLegacy,
'muteAudio': muteAudio,
'manageBluetoothAudio': manageBluetoothAudio,
};
}
}
Expand Down

0 comments on commit e60d459

Please sign in to comment.