Skip to content

Unable to play paused recording using preparePlayer() and resumed recording starts as a new file #506

Open

Description

@SanthoshKumar-Sekar

Bug Description

I found two issues related to recording pause/resume functionality.

Issue 1: Unable to play audio after pausing recording

When a recording is started and then paused, attempting to play the recorded portion of the audio before resuming does not work.

Calling preparePlayer() with the current recording file throws an exception instead of preparing the audio for playback.

Steps to Reproduce

  1. Start audio recording.
  2. Pause the recording.
  3. Call preparePlayer() with the current recording file.
  4. Try to play the recorded audio.

Expected Behavior

  • The audio recorded before pausing should be playable.
  • preparePlayer() should prepare the partially recorded file without throwing an exception.

Actual Behavior

  • preparePlayer() throws an exception.
  • Playback of the recorded portion is not possible while the recording is paused.

** Code **
void pauseAndResumeAudio(String audioRecorderPath) async {

if (recorderController.isRecording) {

  await recorderController.pause();
  await playerController.preparePlayer(
      path: chatPageBloc!.audioRecorderPath,
    
    );
} else if (!recorderController.isRecording) {

  await recorderController.record(
    path: audioRecorderPath,
  );
}

}

Exception:


I/ExoPlayerImpl( 6926): Init 7aa4154 [ExoPlayerLib/2.17.1] [RE606FL1, RMX3853, realme, 36]
E/ExoPlayerImplInternal( 6926): Playback error
E/ExoPlayerImplInternal( 6926):   com.google.android.exoplayer2.ExoPlaybackException: Source error
E/ExoPlayerImplInternal( 6926):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:641)
E/ExoPlayerImplInternal( 6926):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:613)
E/ExoPlayerImplInternal( 6926):       at android.os.Handler.dispatchMessage(Handler.java:111)
E/ExoPlayerImplInternal( 6926):       at android.os.Looper.loopOnce(Looper.java:302)
E/ExoPlayerImplInternal( 6926):       at android.os.Looper.loop(Looper.java:412)
E/ExoPlayerImplInternal( 6926):       at android.os.HandlerThread.run(HandlerThread.java:85)
E/ExoPlayerImplInternal( 6926):   Caused by: com.google.android.exoplayer2.upstream.FileDataSource$FileDataSourceException
E/ExoPlayerImplInternal( 6926):       at com.google.android.exoplayer2.upstream.FileDataSource.open(FileDataSource.java:117)
E/ExoPlayerImplInternal( 6926):       at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:258)
E/ExoPlayerImplInternal( 6926):       at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
E/ExoPlayerImplInternal( 6926):       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1009)
E/ExoPlayerImplInternal( 6926):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
E/ExoPlayerImplInternal( 6926):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1100)
E/ExoPlayerImplInternal( 6926):       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
E/ExoPlayerImplInternal( 6926):       at java.lang.Thread.run(Thread.java:1572)
E/flutter ( 6926): [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(AudioWaveforms, Source error, Unable to load media source., null)
E/flutter ( 6926): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
E/flutter ( 6926): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:367:18)
E/flutter ( 6926): <asynchronous suspension>
E/flutter ( 6926): #2      AudioWaveformsInterface.preparePlayer (package:audio_waveforms/src/base/audio_waveforms_interface.dart:109:18)
E/flutter ( 6926): <asynchronous suspension>
E/flutter ( 6926): #3      PlayerController.preparePlayer (package:audio_waveforms/src/controllers/player_controller.dart:138:24)
E/flutter ( 6926): <asynchronous suspension>


Issue 2: Resume recording creates a new recording instead of continuing

After pausing a recording, resuming it does not continue writing to the existing recording.

Steps to Reproduce

  1. Start audio recording.
  2. Pause the recording.
  3. Resume recording.
  4. Stop the recording and inspect the output.

Expected Behavior

  • Recording should continue from where it was paused.
  • The final audio file should contain both the audio recorded before the pause and after the resume.

Actual Behavior

  • Resuming starts a new recording instead of continuing the existing one.
  • The previously recorded audio is not included in the final output.

** Code **

void pauseAndResumeAudio(String audioRecorderPath) async { 

if (recorderController.isRecording) {
     
      await recorderController.pause();

     
        playerController.notifyListeners();

       
    } else if (!recorderController.isRecording) {
    
      await recorderController.record(
        path: audioRecorderPath,
      );
    }
    
  

}

Additional Information

  • Package: audio_waveforms: ^1.3.0
  • The issue occurs when using the recorder's pause/resume functionality along with preparePlayer() for playback of the partially recorded audio.
  • Any guidance on whether this is the expected behavior or a bug would be appreciated.

@yuanhoujun @yohom @AlexV525 @mattbajorek @rlee1990 @ujas-m-simformsolutions @dhyash-simform
Have a look at this issue:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions