Skip to content

Commit f568d88

Browse files
Merge pull request #29 from SimformSolutionsPvtLtd/feature/scroll-postion-time
✨ scroll timer listener
2 parents 77f92d9 + 4ddcfa1 commit f568d88

18 files changed

+316
-130
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ platform :ios, '10.0'
4545
dependencies:
4646
audio_waveforms: <latest-version>
4747
```
48-
*Get the latest version in the 'Installing' tab on [pub.dev](https://pub.dev/packages/audiowaveforms)*
48+
*Get the latest version in the 'Installing' tab on [pub.dev](https://pub.dev/packages/audio_waveforms)*
4949

5050
2. Import the package.
5151
```dart
@@ -54,7 +54,7 @@ import 'package:audio_waveforms/audio_waveforms.dart';
5454

5555
## Usage
5656

57-
1. Initialise WaveController
57+
1. Initialise RecorderController
5858
```dart
5959
late final RecorderController recorderController;
6060
@@ -88,7 +88,7 @@ final path = await recorderController.stop();
8888
```
8989
Calling this will save the recording at provided path and it will return path to that file.
9090

91-
6. Disposing WaveController
91+
6. Disposing RecorderController
9292
```dart
9393
@override
9494
void dispose() {
@@ -157,7 +157,7 @@ late final RecorderController recorderController;
157157
```
158158
7. Using different types of encoders and sample rate
159159
```dart
160-
late final RecorderController waveController;
160+
late final RecorderController recorderController;
161161
@override
162162
void initState() {
163163
super.initState();
@@ -168,6 +168,12 @@ late final RecorderController waveController;
168168
..sampleRate = 16000;
169169
}
170170
```
171+
8. Listening scrolled duration position
172+
```dart
173+
recorderController.currentScrolledDuration.addListener((duration){});
174+
```
175+
To use this `shouldCalculateScrolledPosition` flag needs to be enabled. Duration is
176+
in milliseconds.
171177

172178
### Player
173179

@@ -186,6 +192,7 @@ void initState() {
186192
await playerController.preparePlayer(path);
187193
```
188194
Provide the audio file path in the parameter. You can also set volume with optional parameter.
195+
189196
3. Use widget in widget-tree
190197
```dart
191198
AudioFileWaveforms(
@@ -198,6 +205,7 @@ AudioFileWaveforms(
198205
await playerController.startPlayer();
199206
```
200207
As default when audio ends it will be seeked to start but you can pass false let it stay at end.
208+
201209
5. Pause player
202210
```dart
203211
await playerController.pausePlayer();

example/assets/audios/audio1.mp3

1.04 MB
Binary file not shown.

example/assets/audios/audio2.mp3

150 KB
Binary file not shown.

example/assets/audios/audio3.mp3

1.61 MB
Binary file not shown.

example/assets/audios/audio4.mp3

434 KB
Binary file not shown.

example/assets/images/logo.png

2.18 KB
Loading

example/lib/chat_bubble.dart

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,42 +58,43 @@ class WaveBubble extends StatelessWidget {
5858

5959
@override
6060
Widget build(BuildContext context) {
61-
return Padding(
62-
padding: const EdgeInsets.only(left: 20, bottom: 10, right: 20),
63-
child: Row(
64-
children: [
65-
if (isSender) ...[
66-
const Spacer(),
61+
return Align(
62+
alignment: isSender ? Alignment.centerRight : Alignment.centerLeft,
63+
child: Container(
64+
padding: EdgeInsets.only(
65+
bottom: 6,
66+
right: isSender ? 0 : 10,
67+
top: 6,
68+
),
69+
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
70+
decoration: BoxDecoration(
71+
borderRadius: BorderRadius.circular(10),
72+
color: isSender ? const Color(0xFF276bfd) : const Color(0xFF343145),
73+
),
74+
child: Row(
75+
mainAxisSize: MainAxisSize.min,
76+
children: [
6777
IconButton(
6878
onPressed: onTap,
6979
icon: Icon(isPlaying ? Icons.stop : Icons.play_arrow),
7080
color: Colors.white,
81+
splashColor: Colors.transparent,
82+
highlightColor: Colors.transparent,
7183
),
72-
],
73-
AudioFileWaveforms(
74-
size: Size(MediaQuery.of(context).size.width / 2, 70),
75-
decoration: BoxDecoration(
76-
borderRadius: BorderRadius.circular(10),
77-
color: const Color(0xFF343145),
78-
),
79-
padding:
80-
const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
81-
clipBehavior: Clip.hardEdge,
82-
playerController: playerController,
83-
density: 1.5,
84-
playerWaveStyle: const PlayerWaveStyle(
85-
scaleFactor: 0.8,
86-
fixedWaveColor: Colors.white,
87-
liveWaveColor: Colors.deepPurpleAccent,
88-
),
89-
),
90-
if (!isSender)
91-
IconButton(
92-
onPressed: onTap,
93-
icon: Icon(isPlaying ? Icons.stop : Icons.play_arrow),
94-
color: Colors.white,
84+
AudioFileWaveforms(
85+
size: Size(MediaQuery.of(context).size.width / 2, 70),
86+
playerController: playerController,
87+
density: 1.5,
88+
playerWaveStyle: const PlayerWaveStyle(
89+
scaleFactor: 0.8,
90+
fixedWaveColor: Colors.white30,
91+
liveWaveColor: Colors.white,
92+
waveCap: StrokeCap.butt,
93+
),
9594
),
96-
],
95+
if (isSender) const SizedBox(width: 10),
96+
],
97+
),
9798
),
9899
);
99100
}

0 commit comments

Comments
 (0)