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

[HELP]: onProgress Stream is not consistent in between pause and start recording #741

Open
Haidar0096 opened this issue Aug 9, 2021 · 7 comments
Labels
help wanted Extra attention is needed Not yet handled

Comments

@Haidar0096
Copy link


I need Help for :

  • Using the API ? Flutter Sound

Here is my question :

I am using BLoC pattern, I send to my UI a Stream so they can display the time elapsed since I started recording, and that time should be stopped if the recorder is paused, and then continued when the recorder is resumed again.

My approach now is to map the onProgress Stream to a new Stream and use StreamBuilder in the UI to update the progress.

However, when I pause then resume the recording, the onProgress Stream starts sending durations again starting from zero, as if it had forgotten the real progress that was reached.

Is this inconsistent behaviour intended or Am I using the API wrong?

I can provide sample code if requested

@Haidar0096 Haidar0096 added help wanted Extra attention is needed Not yet handled labels Aug 9, 2021
@Larpoux
Copy link
Collaborator

Larpoux commented Aug 9, 2021

No. If I understand you clearly this is no intended.
If you look to the Demo Example, you can see that the onProgress stream is correctly paused and resumed with the Pause button.
Are you sure not to call startRecorder() instead of resumeRecorder() ?

Yes, sample code can be useful.
Also :

  • do you do your tests on iOS or Android, ?
  • on an emulator or a real device ?
  • result of flutter pub deps | grep grep flutter_sound
  • your logs

@Haidar0096
Copy link
Author

Haidar0096 commented Aug 10, 2021

  • Code:
    This code is inside my intiRecorder() function
await _recorder.openAudioSession();
      _recorder.setSubscriptionDuration(
        Duration(milliseconds: 100),
      ); //rate at which duration updates are fired
      _durationStream = _recorder.onProgress!.map((event) =>
          event.duration); //this is the stream that I return to my UI

This code is inside my startRecorder

await _recorder.startRecorder(
     toFile: path,
   );

This code is inside my resumeRecorder

await _recorder.resumeRecorder();
            Duration last =
                previousRecorderState.durationSinceStart ?? Duration.zero;
            _recorderState = RecorderState.recording(
                durationSinceStart:
                    _durationStream!.map((event) => last + event));//here I tried to get the last element of the onProgress stream and add it to every element emitted in the new onProgress stream, assuming as I said in the post, it is resetting after resume, but this didn't work even
  • I am running on real device
  • I am testing on android
  • result of flutter pub deps | grep grep flutter_sound
grep: flutter_sound: No such file or directory
Unhandled exception:
FileSystemException: writeFrom failed, path = '' (OS Error: Broken pipe, errno = 32)
#0      _RandomAccessFile.writeFromSync (dart:io/file_impl.dart:870:7)
#1      _StdConsumer.addStream.<anonymous closure> (dart:io/stdio.dart:286:15)
#2      _rootRunUnary (dart:async/zone.dart:1362:47)
#3      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#4      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#6      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#7      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#8      _StreamController._add (dart:async/stream_controller.dart:607:7)
#9      _StreamController.add (dart:async/stream_controller.dart:554:5)
#10     _StreamSinkImpl.add (dart:io/io_sink.dart:136:17)
#11     _IOSinkImpl.write (dart:io/io_sink.dart:269:5)
#12     _IOSinkImpl.writeln (dart:io/io_sink.dart:289:5)
#13     _StdSink.writeln (dart:io/stdio.dart:319:11)
#14     _printToStream (package:pub/src/log.dart:508:10)
#15     _logToStream (package:pub/src/log.dart:492:3)
#16     _logToStdout (package:pub/src/log.dart:471:3)
#17     write (package:pub/src/log.dart:234:27)
#18     message (package:pub/src/log.dart:209:26)
#19     DepsCommand.runProtected (package:pub/src/command/deps.dart:87:5)
#20     new Future.sync (dart:async/future.dart:218:31)
#21     captureErrors.wrappedCallback (package:pub/src/utils.dart:113:12)
#22     _rootRun (dart:async/zone.dart:1354:13)
#23     _CustomZone.run (dart:async/zone.dart:1258:19)
#24     _runZoned (dart:async/zone.dart:1789:10)
#25     runZonedGuarded (dart:async/zone.dart:1777:12)
#26     captureErrors (package:pub/src/utils.dart:130:5)
#27     PubCommand.run (package:pub/src/command.dart:164:13)
#28     CommandRunner.runCommand (package:args/command_runner.dart:196:27)
#29     PubCommandRunner.runCommand (package:pub/src/command_runner.dart:150:26)
#30     PubCommandRunner.run (package:pub/src/command_runner.dart:138:18)
#31     main (file:///b/s/w/ir/cache/builder/src/third_party/dart/third_party/pkg/pub/bin/pub.dart:9:48)
#32     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:281:32)
#33     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
pub finished with exit code 255

@Haidar0096
Copy link
Author

And also a note: the documentation is not very helpful alot of times

For example here on the website of tau project in the section of onProgress it mentions a link to what is supposed to be a simple demo about using onProgress, but if you go to the link (on github) you find a simple demo about the usage of the recorder but without any mentioning of the onProgress. I know it maybe take you alot of time to fix the documentation but I just wanted to shed the light on this problem.

@Larpoux
Copy link
Collaborator

Larpoux commented Aug 10, 2021

the section of onProgress it mentions a link to what is supposed to be a simple demo about using onProgress, but if you go to the link (on github) you find a simple demo about the usage of the recorder but without any mentioning of the onProgress

You are right. The links on this page are wrong.

Where is your Pull Request ?

@dizzersee
Copy link

@Haidar0096 Were you able to resolve the issue?

@Haidar0096
Copy link
Author

@Haidar0096 Were you able to resolve the issue?

It's been a while, but I don't remember solving it.

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Not yet handled
Projects
None yet
Development

No branches or pull requests

3 participants