Skip to content

Commit

Permalink
feat:✨Added support for changing the audio recording quality(#121).
Browse files Browse the repository at this point in the history
  • Loading branch information
jaiminrana05 committed Sep 25, 2023
1 parent 31eedc2 commit 74dc070
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/chatview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ export 'src/values/enumaration.dart';
export 'src/controller/chat_controller.dart';
export 'src/values/typedefs.dart';
export 'package:audio_waveforms/audio_waveforms.dart'
show WaveStyle, PlayerWaveStyle;
show WaveStyle, PlayerWaveStyle,AndroidEncoder,IosEncoder,AndroidOutputFormat;
export 'src/models/receipts_widget_config.dart';
export 'src/extensions/extensions.dart' show MessageTypes;
32 changes: 32 additions & 0 deletions lib/src/models/send_message_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ class VoiceRecordingConfiguration {
this.micIcon,
this.recorderIconColor,
this.stopIcon,
this.sampleRate,
this.bitRate,
this.androidEncoder,
this.iosEncoder,
this.androidOutputFormat,
});

/// Applies styles to waveform.
Expand All @@ -237,4 +242,31 @@ class VoiceRecordingConfiguration {

/// Applies color to mic and stop icon.
final Color? recorderIconColor;

/// Below parameter are use for changing the audio recoding quality.
///The sample-rate for audio in samples per second.
/// Higher the sample-rate, more sample will generate per second,
/// but also larger the file size.
///default value:44100
final int? sampleRate;

/// Bitrate is the amount of data per second that the codec uses to encode
/// the audio.
/// Higher the bitrate, the better the quality, but also larger
/// the file size.
/// default value: null (platform will decide)
final int? bitRate;

/// Audio encoder to be used for recording for IOS
/// default value:IosEncoder.kAudioFormatMPEG4AAC
final IosEncoder? iosEncoder;

/// Audio encoder to be used for recording for Android
/// default value:AndroidEncoder.aac
final AndroidEncoder? androidEncoder;

/// Audio decoder to be used for recording output for Android
/// default value: AndroidOutputFormat.mpeg4
final AndroidOutputFormat? androidOutputFormat;
}
8 changes: 7 additions & 1 deletion lib/src/widgets/chatui_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,13 @@ class _ChatUITextFieldState extends State<ChatUITextField> {
"Voice messages are only supported with android and ios platform",
);
if (!isRecording.value) {
await controller?.record();
await controller?.record(
sampleRate: voiceRecordingConfig?.sampleRate,
bitRate: voiceRecordingConfig?.bitRate,
androidEncoder: voiceRecordingConfig?.androidEncoder,
iosEncoder: voiceRecordingConfig?.iosEncoder,
androidOutputFormat: voiceRecordingConfig?.androidOutputFormat,
);
isRecording.value = true;
} else {
final path = await controller?.stop();
Expand Down

0 comments on commit 74dc070

Please sign in to comment.