Skip to content

Commit 17a2d6b

Browse files
feat: ⚡ Update audio_waveform dependency (#406)
1 parent bb50d24 commit 17a2d6b

File tree

8 files changed

+60
-37
lines changed

8 files changed

+60
-37
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## [3.0.0] (unreleased)
1+
## [3.0.0]
2+
23
* **Feat**: [401](https://github.com/SimformSolutionsPvtLtd/chatview/pull/401)
34
Add selection and copy options for text view.
45
* **Breaking**: [318](https://github.com/SimformSolutionsPvtLtd/chatview/issues/318)
@@ -53,6 +54,11 @@
5354
* **Breaking**: [390](https://github.com/SimformSolutionsPvtLtd/chatview/pull/390) `playIcon` and
5455
`pauseIcon` Now accepts a callback that provides different icons based on whether the message is
5556
by the sender or not. accept `Widget`.
57+
* **Feat**: [390](https://github.com/SimformSolutionsPvtLtd/chatview/pull/406) Updated
58+
audio_waveforms version to `2.0.0`
59+
* **Breaking**: [390](https://github.com/SimformSolutionsPvtLtd/chatview/pull/406) Moved recording
60+
audio settings from `VoiceRecordingConfiguration` to `RecorderSettings`. Check out the migration
61+
guide [here](https://simform-flutter-packages.web.app/chatView/migration-guide).
5662

5763
## [2.5.0]
5864

doc/documentation.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,45 @@ This guide will help you migrate your code from previous versions of ChatView to
11451145

11461146
## Key Changes
11471147

1148+
### Voice Recording Configuration
1149+
1150+
The `VoiceRecordingConfiguration` class has been updated to utilize `RecorderSettings`, which now
1151+
encapsulates the recorder settings for both iOS and Android platforms. The `androidOutputFormat`
1152+
property has been removed so whatever format will be given by the encoder that will be used.
1153+
1154+
Previous Usage:
1155+
```dart
1156+
ChatView(
1157+
sendMessageConfig: SendMessageConfiguration(
1158+
voiceRecordingConfiguration: VoiceRecordingConfiguration(
1159+
sampleRate: 44100,
1160+
bitRate: 128000,
1161+
iosEncoder: IosEncoder.kAudioFormatMPEG4AAC,
1162+
androidEncoder: AndroidEncoder.aacLc,
1163+
androidOutputFormat: AndroidOutputFormat.mpeg4,
1164+
),
1165+
),
1166+
```
1167+
1168+
New Usage:
1169+
```dart
1170+
ChatView(
1171+
sendMessageConfig: SendMessageConfiguration(
1172+
voiceRecordingConfiguration: VoiceRecordingConfiguration(
1173+
recorderSettings: RecorderSettings(
1174+
bitRate: 128000,
1175+
sampleRate: 44100,
1176+
androidEncoderSettings: AndroidEncoderSettings(
1177+
androidEncoder: AndroidEncoder.aacLc,
1178+
),
1179+
iosEncoderSettings: IosEncoderSetting(
1180+
iosEncoder: IosEncoder.kAudioFormatMPEG4AAC,
1181+
),
1182+
),
1183+
),
1184+
),
1185+
```
1186+
11481187
### Text Field Action Items
11491188

11501189
You can now add action buttons to the input field using two builders:

example/lib/widgets/custom_chat_bar.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,8 @@ class _CustomChatBarState extends State<CustomChatBar> {
375375
Future<void> _recordOrStop() async {
376376
if (!isRecording.value) {
377377
await controller?.record(
378-
sampleRate: voiceRecordingConfig.sampleRate,
379-
bitRate: voiceRecordingConfig.bitRate,
380-
androidEncoder: voiceRecordingConfig.androidEncoder,
381-
iosEncoder: voiceRecordingConfig.iosEncoder,
382-
androidOutputFormat: voiceRecordingConfig.androidOutputFormat,
378+
recorderSettings:
379+
voiceRecordingConfig.recorderSettings ?? const RecorderSettings(),
383380
);
384381
isRecording.value = true;
385382
} else {

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
sdk: flutter
1414
cupertino_icons: ^1.0.5
1515
flutter_svg: ^2.2.1
16-
audio_waveforms: ^1.3.0
16+
audio_waveforms: ^2.0.0
1717
chatview:
1818
path: ../
1919
intl:

lib/chatview.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ library chatview;
2525
export 'package:audio_waveforms/audio_waveforms.dart'
2626
show
2727
AndroidEncoder,
28-
AndroidOutputFormat,
28+
AndroidEncoderSettings,
2929
IosEncoder,
30+
IosEncoderSetting,
3031
PlayerWaveStyle,
32+
RecorderSettings,
3133
WaveStyle;
3234
export 'package:chatview_utils/chatview_utils.dart'
3335
hide

lib/src/models/config_models/send_message_configuration.dart

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ class VoiceRecordingConfiguration {
271271
/// Styling configuration for the recorder widget as well as
272272
/// configuring the audio recording quality.
273273
const VoiceRecordingConfiguration({
274+
this.recorderSettings,
274275
this.waveStyle,
275276
this.padding,
276277
this.margin,
@@ -279,11 +280,6 @@ class VoiceRecordingConfiguration {
279280
this.micIcon,
280281
this.recorderIconColor,
281282
this.stopIcon,
282-
this.sampleRate,
283-
this.bitRate,
284-
this.androidEncoder,
285-
this.iosEncoder,
286-
this.androidOutputFormat,
287283
});
288284

289285
/// Applies styles to waveform.
@@ -311,24 +307,10 @@ class VoiceRecordingConfiguration {
311307
/// Applies color to mic and stop icon.
312308
final Color? recorderIconColor;
313309

314-
/// The sample rate for audio is measured in samples per second.
315-
/// A higher sample rate generates more samples per second,
316-
/// resulting in better audio quality but also larger file sizes.
317-
final int? sampleRate;
318-
319-
/// Bitrate is the amount of data per second that the codec uses to
320-
/// encode the audio. A higher bitrate results in better quality
321-
/// but also larger file sizes.
322-
final int? bitRate;
323-
324-
/// Audio encoder to be used for recording for IOS.
325-
final IosEncoder? iosEncoder;
326-
327-
/// Audio encoder to be used for recording for Android.
328-
final AndroidEncoder? androidEncoder;
329-
330-
/// The audio output format to be used for recorded audio files on Android.
331-
final AndroidOutputFormat? androidOutputFormat;
310+
/// Configures audio recording settings for Android and iOS.
311+
///
312+
/// if null, default settings will be used.
313+
final RecorderSettings? recorderSettings;
332314
}
333315

334316
class CancelRecordConfiguration {

lib/src/widgets/chatui_textfield.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,8 @@ class _ChatUITextFieldState extends State<ChatUITextField> {
428428
);
429429
if (!isRecording.value) {
430430
await controller?.record(
431-
sampleRate: voiceRecordingConfig?.sampleRate,
432-
bitRate: voiceRecordingConfig?.bitRate,
433-
androidEncoder: voiceRecordingConfig?.androidEncoder,
434-
iosEncoder: voiceRecordingConfig?.iosEncoder,
435-
androidOutputFormat: voiceRecordingConfig?.androidOutputFormat,
431+
recorderSettings:
432+
voiceRecordingConfig?.recorderSettings ?? const RecorderSettings(),
436433
);
437434
isRecording.value = true;
438435
} else {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ environment:
1717

1818
dependencies:
1919
any_link_preview: ^3.0.2
20-
audio_waveforms: ^1.2.0
20+
audio_waveforms: ^2.0.0
2121
cached_network_image: ^3.4.1
2222
chatview_utils: ^0.0.2
2323

0 commit comments

Comments
 (0)