flutter_sound
Flutter plugin for sound. Audio recorder and player.
This plugin provides simple recorder and player functionalities for both android
and ios
platforms. This only supports default file extension for each platform. This plugin handles file from remote url. This plugin can handle playback stream from native (To sync exact time with bridging).
Install
Add flutter_sound
as a dependency in pubspec.yaml
For help on adding as a dependency, view the documentation.
Post Installation
On iOS you need to add a usage description to info.plist
:
On Android you need to add a permission to AndroidManifest.xml
:
Methods
Func | Param | Return | Description |
---|---|---|---|
setSubscriptionDuration | double sec |
String message |
Set subscription timer in seconds. Default is 0.01 if not using this method. |
startRecorder | String uri |
String uri |
Start recording. This will return uri used. |
stopRecorder | String message |
Stop recording. | |
startPlayer | String uri |
String message |
Start playing. |
stopPlayer | String message |
Stop playing. | |
pausePlayer | String message |
Pause playing. | |
resumePlayer | String message |
Resume playing. | |
seekToPlayer | int milliSecs position to goTo |
String message |
Seek audio to selected position in seconds. Parameter should be less than audio duration to correctly placed. |
Subscriptions
Subscription | Return | Description |
---|---|---|
onRecorderStateChanged | <RecordStatus> |
Able to listen to subscription when recorder starts. |
onPlayerStateChanged | <PlayStatus> |
Able to listen to subscription when player starts. |
Default uri path
When uri path is not set during the function call
in startRecorder
or startPlayer
, they are saved in below path depending on the platform.
- Default path for android
sdcard/sound.mp4
.
- Default path for ios
sound.m4a
.
Usage
Creating instance.
Starting recorder with listener.
Stop recorder
Start player
Stop player
Pause player
Resume player
Seek player
Setting subscription duration (Optional). 0.01 is default value when not set.
Setting volume.
TODO
- [ ] Seeking example in
Exmaple
project - [x] Volume Control
- [x] Sync timing for recorder callback handler