flutter_sound
flutter_sound copied to clipboard
Audio record progress stream not working
audioRecorder.onProgress.listen((event) { print(event.duration); print(event.decibels); });
After starting the recorder I tried this, however nothing gets printed. Can someone help me with this? Thank you.
Did you call setSubscriptionDuration() before starting your recorder ?
await audioRecorder.setSubscriptionDuration(Duration(seconds: 1));
yes I did it this way. Still not working
I will need your logs to help you.
Now, I am going to lunch. I will be back in one hour
Please fill a correct issue :
-
flutter pub deps | grep flutter_sound
- Android or iOS ?
- Real device or emulator ?
- your logs
Tell us also if the recording is correctely done (but nothing received in your onProgress
stream),
or if the recording does not work.
Please understand that if you fill a PR (Problem Report) with just :
onProgress does not work.
And nothing else, nobody will be able to help you
You can also specify :
- The Codec you use for recording
- Do you record to a file or to a Dart stream
All those informations (and many others) can help to understand your problem.
|-- flutter_sound 7.5.1+2 | |-- flutter_sound_platform_interface 7.5.1+2 | |-- flutter_sound_web 7.5.1+2 | | |-- flutter_sound_platform_interface...
Android Pie, Real device
Logs : only this is what is found In stopBluetoothSco(), calling application: com.example.sabrhealthapp I/AudioManager( 5690): In setBluetoothScoOn(), on: false, calling application: com.example.sabrhealthapp I/AudioManager( 5690): In setSpeakerphoneOn(), on: true, calling application: com.example.sabrhealthapp I/AudioManager( 5690): In setSpeakerphoneOn(), on: true, calling application: com.example.sabrhealthapp I/AudioManager( 5690): In setBluetoothScoOn(), on: false, calling application: com.example.sabrhealthapp I/AudioManager( 5690): In stopBluetoothSco(), calling application: com.example.sabrhealthapp
Setting subscription await audioRecorder.setSubscriptionDuration(Duration(seconds: 1));
I'm recoding to a file await audioRecorder.startRecorder(codec: Codec.aacADTS, toFile: filePath);
Audio gets recorded properly
Thank you.
Are you sure that you called setSubscriptionDuration() before startRecorder() and not after ?
yes before, this the module
Future<void> startRecording(String filePath) async {
print('starting to record');
if (!await Permission.microphone.isGranted)
PermissionStatus status = await Permission.microphone.request();
await audioRecorder.setSubscriptionDuration(Duration(seconds: 1));
await audioRecorder.startRecorder(codec: Codec.defaultCodec, toFile: filePath);
audioRecorder.onProgress.listen((event) {
print(event.duration);
print(event.decibels);
});
print('recording');
}
Sorry, I have no idea. This function is supposed to work fine, and is very simple.
There is probably something wrong on your side, but I do not see what.
Future<void> init() async {
print('initiating audio recorder');
audioRecorder = await FlutterSoundRecorder().openAudioSession(
focus: AudioFocus.requestFocusAndStopOthers,
category: SessionCategory.playAndRecord,
mode: SessionMode.modeSpokenAudio,
);
}
this is how I'm opening the audio session
Sorry, I have no idea. This function is supposed to work fine, and is very simple.
There is probably something wrong on your side, but I do not see what.
I tried whatever I could to get it working. Thanks for your attention. Currently using a timer as a work around.
I tried whatever I could to get it working. Thanks for your attention. Currently using a timer as a work around.
Hey man could you share the timer code, please? Thanks!
Thank you.
Are you sure that you called setSubscriptionDuration() before startRecorder() and not after ?
This worked perfectly! thanks! used the new docs btw
This Record Progress is really painful. Many, many developers have problemes with that. Too many. We must improve the API in V9 for that.
We must improve the API in V9 for that.
I think the new docs explained it very well! if there is room for improvement then sure why not
This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.
The current version is the latest version. When recording audio on the iOS simulator, the callback progress is 0. However, it is fine on the Andorid platform.