Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
874 stars 569 forks source link

Audio record progress stream not working #589

Open niteesh1215 opened 3 years ago

niteesh1215 commented 3 years ago

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.

Larpoux commented 3 years ago

Did you call setSubscriptionDuration() before starting your recorder ?

niteesh1215 commented 3 years ago

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

yes I did it this way. Still not working

Larpoux commented 3 years ago

I will need your logs to help you.

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

Larpoux commented 3 years ago

Please fill a correct issue :

Larpoux commented 3 years ago

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 commented 3 years ago

You can also specify :

All those informations (and many others) can help to understand your problem.

niteesh1215 commented 3 years ago

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

Larpoux commented 3 years ago

Thank you.

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

niteesh1215 commented 3 years ago

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

  }
Larpoux commented 3 years ago

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.

niteesh1215 commented 3 years ago
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 commented 3 years ago

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.

Faaatman commented 3 years ago

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 commented 3 years ago

Thank you.

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

This worked perfectly! thanks! used the new docs btw

Larpoux commented 3 years ago

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

Faaatman commented 3 years ago

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

github-actions[bot] commented 10 months ago

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.

Pgrammerybj commented 9 months ago

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.