Tuesday, October 27, 2026
HomeiOS Developmentandroid - Flutter: Why is my app giving an error when attempting...

android – Flutter: Why is my app giving an error when attempting to play again an audio file?

[ad_1]

I’ve an app that data audio when the consumer faucets a button. It writes a brief file to the cell machine, then runs some FFMPEG code to alter the pitch.

The conventional method a consumer would use it’s:

  1. Faucet the button
  2. File the audio (10 seconds)
  3. After recording is finished, play again the audio with the pitch modified

This works high-quality after I do it as soon as, however after I do it a second time (after playback has utterly completed), I can report one other audio file however my console says there was a supply error for playback. I am undecided why it will probably do it as soon as however not twice. I really feel as if the problem is likely to be one thing with async/await. I do not totally perceive when to make use of it so I attempt to keep away from it, however Android Studio compelled me to make use of it for the road last Listing<FileSystemEntity> information = await dir.checklist().toList(); after which I added it all over the place else that I believed kinda made sense however actually it is a mess…

void startTapRecording() {
    print('##MyApp## startTapRecording: 1');
    controller?.cease();
    controller?.reset();
    cancelTimer();
    print('##MyApp## startTapRecording: 2');
    stopPlaying();
    stopRecording();

    last String filename = getNewMyAppAudioFileID();

    setState(() {
      currentMyAppFilename = filename;
    });

    startRecordingTimer();

    print('##MyApp## startTapRecording: 3');

    startRecording(MyAppsInProgressFileDir.path + currentMyAppFilename);

    controller?.ahead();

    print('##MyApp## startTapRecording: 4 (completed)');
}

void startRecording(String filename) async {
    print('##MyApp## startRecording: 1');
    // Request Microphone permission if wanted

    await cleanupTempAudioFiles();

    print('##MyApp## startRecording: 2');

    PermissionStatus standing = await Permission.microphone.request();
    if (standing != PermissionStatus.granted) {
      throw RecordingPermissionException("Microphone permission not granted");
    }

    await myRecorder.startRecorder(toFile: filename); 

    print('##MyApp## startRecording: 3 (completed)');
}


Future<void> cleanupTempAudioFiles() async {
    print('##MyApp## cleanupTempAudioFiles: 1');

    last dir = Listing(MyAppsInProgressFileDir.path);
    last Listing<FileSystemEntity> information = await dir.checklist().toList();

    print('##MyApp## cleanupTempAudioFiles: 2 ');
    information.forEach((file) async {
      print('##MyApp## cleanupTempAudioFiles: file.path=" + file.path);
      if (file.path == MyAppsInProgressFileDir.path + currentMyAppFilename) {
        await file.delete();
        print("##MyApp## cleanupTempAudioFiles: file deleted');
      }

      if (file.path == MyAppsInProgressFileDir.path + currentMyAppFilename + 'Excessive.mp3') {
        await file.delete();
        print('##MyApp## cleanupTempAudioFiles: file deleted Excessive.mp3');
      }

      if (file.path == MyAppsInProgressFileDir.path + currentMyAppFilename + 'Low.mp3') {
        await file.delete();
        print('##MyApp## cleanupTempAudioFiles: file deleted Low.mp3');
      }
    });
    print('##MyApp## cleanupTempAudioFiles: 3 (completed)');
}

Logcat output, filtered on ##MyApp##:

##MyApp## startTapRecording: 1
##MyApp## startTapRecording: 2
##MyApp## startTapRecording: 3
##MyApp## startRecording: 1
##MyApp## cleanupTempAudioFiles: 1
##MyApp## startTapRecording: 4 (completed)
##MyApp## cleanupTempAudioFiles: 2 
##MyApp## cleanupTempAudioFiles: file.path = /information/consumer/0/com.instance.MyApp_3/code_cache/MyApp/MyAppAudioFiles/MyAppsInProgress/MyAppAudioFile1
##MyApp## cleanupTempAudioFiles: file.path = /information/consumer/0/com.instance.MyApp_3/code_cache/MyApp/MyAppAudioFiles/MyAppsInProgress/MyAppAudioFile1High.mp3
##MyApp## cleanupTempAudioFiles: 3 (completed)
##MyApp## startRecording: 2
##MyApp## cleanupTempAudioFiles: file deleted
##MyApp## cleanupTempAudioFiles: file deleted Excessive.mp3
##MyApp## startRecording: 3 (completed)
##MyApp## handleTimeout sendableMyAppExists: 1
##MyApp## runFFMPEGHighLow
##MyApp## startTapRecording: 1
##MyApp## startTapRecording: 2
##MyApp## startTapRecording: 3
##MyApp## startRecording: 1
##MyApp## cleanupTempAudioFiles: 1
##MyApp## startTapRecording: 4 (completed)
##MyApp## cleanupTempAudioFiles: 2 
##MyApp## cleanupTempAudioFiles: file.path = /information/consumer/0/com.instance.MyApp_3/code_cache/MyApp/MyAppAudioFiles/MyAppsInProgress/MyAppAudioFile1
##MyApp## cleanupTempAudioFiles: file.path = /information/consumer/0/com.instance.MyApp_3/code_cache/MyApp/MyAppAudioFiles/MyAppsInProgress/MyAppAudioFile1High.mp3
##MyApp## cleanupTempAudioFiles: 3 (completed)
##MyApp## startRecording: 2
##MyApp## cleanupTempAudioFiles: file deleted
##MyApp## cleanupTempAudioFiles: file deleted Excessive.mp3
##MyApp## startRecording: 3 (completed)
##MyApp## handleTimeout sendableMyAppExists: 1
##MyApp## runFFMPEGHighLow

The error within the console:

E/ExoPlayerImplInternal(20582): Playback error
E/ExoPlayerImplInternal(20582):   com.google.android.exoplayer2.ExoPlaybackException: Supply error
E/ExoPlayerImplInternal(20582):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:624)
E/ExoPlayerImplInternal(20582):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:594)
E/ExoPlayerImplInternal(20582):       at android.os.Handler.dispatchMessage(Handler.java:102)
E/ExoPlayerImplInternal(20582):       at android.os.Looper.loopOnce(Looper.java:226)
E/ExoPlayerImplInternal(20582):       at android.os.Looper.loop(Looper.java:313)
E/ExoPlayerImplInternal(20582):       at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal(20582):   Brought on by: com.google.android.exoplayer2.supply.UnrecognizedInputFormatException: Not one of the accessible extractors (Mp3Extractor, FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, JpegExtractor) may learn the stream.
E/ExoPlayerImplInternal(20582):       at com.google.android.exoplayer2.supply.BundledExtractorsAdapter.init(BundledExtractorsAdapter.java:92)
E/ExoPlayerImplInternal(20582):       at com.google.android.exoplayer2.supply.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1025)
E/ExoPlayerImplInternal(20582):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:409)
E/ExoPlayerImplInternal(20582):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal(20582):       at java.util.concurrent.ThreadPoolExecutor$Employee.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal(20582):       at java.lang.Thread.run(Thread.java:920)
E/AudioPlayer(20582): TYPE_SOURCE: Not one of the accessible extractors (Mp3Extractor, FlvExtractor, FlacExtractor, WavExtractor, FragmentedMp4Extractor, Mp4Extractor, AmrExtractor, PsExtractor, OggExtractor, TsExtractor, MatroskaExtractor, AdtsExtractor, Ac3Extractor, Ac4Extractor, JpegExtractor) may learn the stream.
I/ExoPlayerImpl(20582): Launch cc7756c [ExoPlayerLib/2.15.0] [o1q, SM-G991U, samsung, 31] [goog.exo.core]
E/flutter (20582): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: (0) Supply error
E/flutter (20582): #0      AudioPlayer._load (bundle:just_audio/just_audio.dart:798:9)
E/flutter (20582): <asynchronous suspension>
E/flutter (20582): #1      AudioPlayer._setPlatformActive.setPlatform (bundle:just_audio/just_audio.dart:1365:28)
E/flutter (20582): <asynchronous suspension>
E/flutter (20582): 

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments