flutter_sound icon indicating copy to clipboard operation
flutter_sound copied to clipboard

Audio record progress stream not working

Open niteesh1215 opened this issue 4 years ago • 18 comments

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.

niteesh1215 avatar Jan 17 '21 10:01 niteesh1215

Did you call setSubscriptionDuration() before starting your recorder ?

Larpoux avatar Jan 17 '21 10:01 Larpoux

await audioRecorder.setSubscriptionDuration(Duration(seconds: 1));

yes I did it this way. Still not working

niteesh1215 avatar Jan 17 '21 11:01 niteesh1215

I will need your logs to help you.

Now, I am going to lunch. I will be back in one hour

Larpoux avatar Jan 17 '21 11:01 Larpoux

Please fill a correct issue :

  • flutter pub deps | grep flutter_sound
  • Android or iOS ?
  • Real device or emulator ?
  • your logs

Larpoux avatar Jan 17 '21 11:01 Larpoux

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

Larpoux avatar Jan 17 '21 11:01 Larpoux

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.

Larpoux avatar Jan 17 '21 11:01 Larpoux

|-- 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

niteesh1215 avatar Jan 17 '21 11:01 niteesh1215

Thank you.

Are you sure that you called setSubscriptionDuration() before startRecorder() and not after ?

Larpoux avatar Jan 17 '21 13:01 Larpoux

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');

  }

niteesh1215 avatar Jan 17 '21 14:01 niteesh1215

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.

Larpoux avatar Jan 17 '21 14:01 Larpoux

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

niteesh1215 avatar Jan 17 '21 14:01 niteesh1215

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.

niteesh1215 avatar Jan 17 '21 14:01 niteesh1215

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!

Faaatman avatar Aug 11 '21 20:08 Faaatman

Thank you.

Are you sure that you called setSubscriptionDuration() before startRecorder() and not after ?

This worked perfectly! thanks! used the new docs btw

Faaatman avatar Aug 17 '21 18:08 Faaatman

This Record Progress is really painful. Many, many developers have problemes with that. Too many. We must improve the API in V9 for that.

Larpoux avatar Aug 17 '21 18:08 Larpoux

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

Faaatman avatar Aug 17 '21 18:08 Faaatman

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.

github-actions[bot] avatar Dec 18 '23 01:12 github-actions[bot]

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.

Pgrammerybj avatar Dec 20 '23 08:12 Pgrammerybj