question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG]: onProgress stream never completes, not sure if intended

See original GitHub issue

Flutter sound onProgress stream never completes. Looking at the source, it seem to have been intended this way.

However I believe semantically speaking it should complete. It would allow things like this:

  Stream<RecordingDisposition> record(String path) {
    assert(_recorder.isStopped);
    return Stream.fromFuture(_doRecord(path))
        .switchMap((_) => _recorder.onProgress!)
        .doOnDone(() => _closeRecorderSession());
  }

  Future<void> _doRecord(String path) async {
    await _openRecorderSession();
    await _recorder.setSubscriptionDuration(const Duration(milliseconds: 100));
    await _recorder.startRecorder(
      toFile: path,
      codec: kIsWeb ? Codec.opusWebM : Codec.aacADTS,
    );
  }

It also has potential for unnecessary active subscriptions and might be the source of other bugs.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cedvdbcommented, Aug 6, 2021

How about returning a stream from the startRecord/startPlaying instead ? Or is that too much breaking change ?

  Stream<PlaybackDisposition> startPlayer({
   String? fromURI,
   Uint8List? fromDataBuffer,
   Codec codec = Codec.aacADTS,
   int sampleRate = 16000, // Used only with codec == Codec.pcm16
   int numChannels = 1, // Used only with codec == Codec.pcm16
   TWhenFinished? whenFinished,
 }) {
   _progressController = StreamController();
   _lock.synchronized(() async {
     await _startPlayer(
       fromURI: fromURI,
       fromDataBuffer: fromDataBuffer,
       codec: codec,
       sampleRate: sampleRate,
       numChannels: numChannels,
       whenFinished: whenFinished,
     );
   });
   return _progressController!.stream.asBroadcastStream();
 }

I’m not sure what the lock is, if I understood correctly it’s to be sure the callback is executed only once at a time, if that’s the case then the way the progress is initialized is not entirely correct. his.

usage

_player.play().listen(
    (progress) => print(progress), 
    onDone: (duration) => _playNextTrack(), 
    onError: (e) => _displayError(e)
 );
0reactions
AR553commented, Jun 29, 2022

Any update on this issue? Can we alternatively check if the player has completed playing the audio?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Media Source Extensions™ - W3C
Abstract. This specification extends HTMLMediaElement [ HTML ] to allow JavaScript to generate media streams for playback.
Read more >
ProgressBar - Android Developers
Use indeterminate mode for the progress bar when you do not know how long an operation ... to increase the current progress completed...
Read more >
1348087 - Use standard networking download code instead of ...
We assume that the download is complete at >+ * this point. ... Not sure what will need to be done to make...
Read more >
Murphy's Laws - Cheap Thoughts
Murphy's Time-Action Quandary: You never know how soon is too late. ... Rahilly's Law of Academic Administration: Remember that not all the faculty...
Read more >
Project Status Reports - ProjectManager
Reporting software can also be cloud-based, which means that it gathers data in real-time. No matter how fast you can manually calculate, you'll...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found