1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter audio_session: PlatformException(record, The operation couldn’t be...

Discussão em 'Mobile' iniciado por Stack, Outubro 16, 2024 às 14:52.

  1. Stack

    Stack Membro Participativo

    I'm trying to work on the reconnection of an audio stream after the stream's unexpected interruption by turning off my second device and turning back it on. This error appears when the reconnection process starts and the Iphone is locked:

    [aurioc] AURemoteIO.cpp:1668 AUIOClient_StartIO failed (561145187)

    [avae] AVAEInternal.h:109 [AVAudioEngineGraph.mm:1545:Start: (err = PerformCommand(*ioNode, kAUStartIO, NULL, 0)): error 561145187

    Flutter : PlatformException(record, The operation couldn’t be completed. (com.apple.coreaudio.avfaudio error 561145187.), null, null)

    I've seen that this error code is : AVAudioSession.ErrorCode.cannotStartRecording.
    Also, weird behavior, the first few tries always fail, but if I hot restart the app and try again the error disappears and the call successfully reconnects.

    I've seen some people facing the same type of issue on the net but none of their solutions works for me. I tried to include this:

    Future<AudioSession> configureAudioSession() async {
    final session = await AudioSession.instance;
    await session.configure(AudioSessionConfiguration(
    avAudioSessionCategory: AVAudioSessionCategory.playAndRecord,
    avAudioSessionCategoryOptions: AVAudioSessionCategoryOptions.defaultToSpeaker |
    AVAudioSessionCategoryOptions.mixWithOthers |
    AVAudioSessionCategoryOptions.allowBluetooth |
    AVAudioSessionCategoryOptions.interruptSpokenAudioAndMixWithOthers,
    avAudioSessionMode: AVAudioSessionMode.voiceChat,
    avAudioSessionRouteSharingPolicy: AVAudioSessionRouteSharingPolicy.defaultPolicy,
    avAudioSessionSetActiveOptions: AVAudioSessionSetActiveOptions.notifyOthersOnDeactivation,
    androidAudioAttributes: const AndroidAudioAttributes(
    contentType: AndroidAudioContentType.speech,
    flags: AndroidAudioFlags.none,
    usage: AndroidAudioUsage.voiceCommunication,
    ),
    androidAudioFocusGainType: AndroidAudioFocusGainType.gain,
    androidWillPauseWhenDucked: true,
    ));
    return session;
    }


    Before doing this:

    final stream = await audioRecorder.startStream(const RecordConfig(
    encoder: AudioEncoder.pcm16bits,
    bitRate: audioRecorderChannelCount * BabyMonitorCallService.sampleRate * 16,
    sampleRate: BabyMonitorCallService.sampleRate,
    numChannels: audioRecorderChannelCount,
    autoGain: true,
    noiseSuppress: true));

    final streamSub = await _subscribeToPcm16Stream(stream, onFrame);


    But still nothing is changing I still have this error over and over.

    Continue reading...

Compartilhe esta Página