Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android recorded duration is not same as controller duration #236

Open
emreerkaslan opened this issue Jul 28, 2023 · 3 comments
Open

Android recorded duration is not same as controller duration #236

emreerkaslan opened this issue Jul 28, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@emreerkaslan
Copy link

What I do is recording audio via RecorderController:

late RecorderController controller;
controller.onCurrentDuration.listen((duration) {
      if (duration >= Duration(seconds: 5) {
        _stopRecording(context);
      }
    });;

Then I check the recorded duration via PlayerController:

late PlayerController player;
  _stopRecording(BuildContext context) async {
    final voicePath = await controller.stop();
   await player.preparePlayer(
      path: voicePath,
      shouldExtractWaveform: true,
      noOfSamples: 56,
      volume: 1.0,
    );

print("${player.maxDuration}");
  }

Basically, ios works fine. In android, controller duration is 5 seconds but when player.maxDuration is printed it is 4.860 seconds so there is a difference between recorded time and controller time.

I expect two values to be same or at least work same on both platforms.

  • Device: Samsung S21
  • OS: One UI Version 5.1
  • Android Version: Android 13
@ujas-m-simformsolutions ujas-m-simformsolutions added the in triage The issue is being triaged label Aug 14, 2023
@ujas-m-simformsolutions
Copy link
Collaborator

@emreerkaslan The stream you are using is not that accurate, as mentioned in the documentation. It will start or stop when it gets a callback from the native. So there can be some variation in milliseconds. And even if you do this in native alone, there can be some variations. So I would suggest that for your use case, instead of using stream, try using `Future.delay. It may or may not give you the closest results.

@ujas-m-simformsolutions ujas-m-simformsolutions added waiting-for-response Waiting for someone to respond. and removed in triage The issue is being triaged labels Aug 14, 2023
@emreerkaslan
Copy link
Author

Indeed, I did that 2 weeks ago. I think it is not a good workaround though. Do you think two streams can be aligned? I would like to help if it's possible somehow.

@ujas-m-simformsolutions ujas-m-simformsolutions removed the waiting-for-response Waiting for someone to respond. label Aug 16, 2023
@ujas-m-simformsolutions
Copy link
Collaborator

I have found native methods for this on Android and iOS, so this will be a good enhancement for the package.

@ujas-m-simformsolutions ujas-m-simformsolutions added the enhancement New feature or request label Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants