audio_waveforms icon indicating copy to clipboard operation
audio_waveforms copied to clipboard

onCurrentExtractedWaveformData

Open Kamoba opened this issue 1 year ago • 3 comments

Using onCurrentExtractedWaveformData

_audioPlayer.onCurrentExtractedWaveformData.listen((data) {
      extractionWave = data;
     },
      onDone: () { // this never runs
         print("done");
        //saveWave(extractionWave);
        extractionWaveDone = true;
      },
      onError: (Object e, StackTrace stackTrace) { // this look never runs as well
        print('A stream error occurred: $e');
        //extractionWave = [];
      },  
      cancelOnError: false
    );

Bug 1: onDone never runs (tested, no logs). for now just trying to implement something using: _audioPlayer.onCurrentExtractedWaveformData.elementAt(noOfSamples -1).then((data) {

Bug 2: Once a while when the waveform is not rendered well and i check for errors i do not see my logs, look like onError do not runs also.

Bug 3: Starting new extration do not stop the previous extraction. To reproduce, using the player, play audio1 using: await _audioPlayer.preparePlayer with shouldExtractWaveform = true. Then quickly (before audio1 finish extraction), play audio2 then you will receive both data alternatively without any way to differentiate them. For now I'm trying to check data[0] (saved when it start) to determine which one it is.

Using last version of flutter (3.22.2) and this package.

Kamoba avatar Aug 01 '24 02:08 Kamoba

Any updates about Bug 3? Is there a way to bypass the wait for the previous audio?

Henriquek47 avatar Aug 13 '24 16:08 Henriquek47

Hello @Kamoba,

Bug 1: onDone never runs (tested, no logs). This is because we are not closing the stream as users can extract multiple waveforms from the same instance.

Bug 2: Once a while when the waveform is not rendered well and i check for errors i do not see my logs, look like onError do not runs also. - if possible can you share block of code where you facing error so i can check.

Bug 3: Starting new extration do not stop the previous extraction. Can you please make sure that you aren't using the same instance of PlayerController when extracting waveforms from multiple audios. If you are then you will need to use another instance or wait for previous one to complete.

Thank you,

himanshuGandhiSimform avatar Oct 14 '24 11:10 himanshuGandhiSimform

@himanshuGandhiSimform Bug 1: At least provide a method to close it, because previous stream will become parasite for users that do not need it and will be forced to implement a way to skip them.

Bug 2: Unfortunately i do not have an example in mind, just simple play audio that extract automatically the wave. Playing it many time getting normally something like 40 waveform and time to time (3% of the time, so not easy to reproduce) get some random low number like 1 or 3 waveform without error. Now I'm thinking this may be caused by Bug1... but, wait a minute, no because I implemented my own way to filter "parasite waveform" and can still see it time to time.

Bug 3: Yes I use the same instance because I need to do play, pause, and resume.

Kamoba avatar Oct 14 '24 20:10 Kamoba