Open Haidar0096 opened 3 years ago
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 :
flutter pub deps | grep grep flutter_sound
intiRecorder()
functionawait _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
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
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.
the section of
onProgress
it mentions a link to what is supposed to be a simple demo about usingonProgress
, 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 theonProgress
You are right. The links on this page are wrong.
Where is your Pull Request ?
@Haidar0096 Were you able to resolve the issue?
@Haidar0096 Were you able to resolve the issue?
It's been a while, but I don't remember solving it.
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.
I need Help for :
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