Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
850 stars 553 forks source link

[BUG]:When try to record the audio then it is not recording sometimes. Mean if we kill application then run the code directly then it is working. But going from some login flow or something then it is not working ( Only in IOS Plaftfrom ) #1037

Closed neeraj92144 closed 1 month ago

neeraj92144 commented 1 month ago

Lib Verison - flutter_sound: ^9.2.12 Flutter version - flutter_macos_arm64_3.16.0-stable

App Code -

@override void initState() { super.initState(); initRecorder(); }

@override void dispose() { super.dispose(); recorder.closeRecorder(); audioPlayer.stop(); audioPlayer.dispose();

}

Future initRecorder() async { final status = await Permission.microphone.request(); if (status != PermissionStatus.granted) { throw 'Microphone permission not granted'; } recorder.setLogLevel(Level.debug); await recorder.openRecorder(); // _recorderSubscription = recorder.onProgress!.listen((e) { // setState(() { // updatedTime = "${e.duration.inMinutes}:${e.duration.inSeconds}"; // }); // }); isRecorderReady = true; }

startStop() async { final status = await Permission.microphone.status; if (status != PermissionStatus.granted) { Common.showWaterToast("Microphone permission not granted",context); throw 'Microphone permission not granted'; } if (recorder.isRecording) { // Common.showWaterToast("Recording",context); await stop(); } else { // Common.showWaterToast("Record",context); await record(); } Future.delayed(const Duration(milliseconds: 300), () { setState(() {}); }); }

Future record() async { // Common.showWaterToast("record",context);

if (!isRecorderReady) return;
// Common.showWaterToast("record2",context);

setState(() {
  currentFilePath =
      'recored_audio_${DateTime.now().millisecondsSinceEpoch}.mp4';
});
var _codec = FlutterSound
    .Codec.aacMP4; // Use the Codec enumeration from FlutterSound

    if(recorder == null) {
      print("Recoder Null Null Null")
    }

await recorder
    .startRecorder(codec: _codec, toFile: currentFilePath)
    .then((value) async {
  // Common.showWaterToast("record3",context);

await recorder.setSubscriptionDuration( const Duration(milliseconds: 1000), ); // setState(() {}); Future.delayed(const Duration(milliseconds: 300), () async {

    setState(() {});
  });
});
setState(() {
  audioElementEnable = true;
});

}

Future stop() async { // Common.showWaterToast("stop",context);

if (!isRecorderReady) return;

// Common.showWaterToast("stop2",context);

final path = await recorder.stopRecorder();
print("stopPath ${path}");
selectedAudioFile = File(path!);
selectedAudioFilePath = path!;
setState(() {
  isAudioReady = true;
});
print("Recored audio : $selectedAudioFile");

}

Please reply fast so I can fix this, right away, Thanks in advance

Larpoux commented 1 month ago

Is it possible to have the traces?

neeraj92144 commented 1 month ago

Yes, sure, Below is logs , have a look

flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 new FlutterSoundRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:140:13) flutter: │ #1 new NewHomeChatState (package:wateringtogether/screens/Chat/NewHomeChat.dart:96:33) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 ctor: FlutterSoundRecorder() flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.openRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:372:13) flutter: │ #1 NewHomeChatState.initRecorder (package:wateringtogether/screens/Chat/NewHomeChat.dart:1000:20) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:---> openAudioSession flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder._openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:381:13) flutter: │ #1 FlutterSoundRecorder.openRecorder. (package:flutter_sound/public/flutter_sound_recorder.dart:374:17) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 ---> openAudioSession flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder._openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:396:17) flutter: │ #1 FlutterSoundRecorder.openRecorder. (package:flutter_sound/public/flutter_sound_recorder.dart:374:17) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 Resetting flutter_sound Recorder Plugin flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── iOS: resetPlugin flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.openRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:171:13) flutter: │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:98:22) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 ---> openRecorderCompleted: true flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.openRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:182:13) flutter: │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:98:22) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 <--- openRecorderCompleted: true flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder._openAudioSession (package:flutter_sound/public/flutter_sound_recorder.dart:412:13) flutter: │ #1 flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 <--- openAudioSession flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.openRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:376:13) flutter: │ #1 flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:<--- openAudioSession flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:590:13) flutter: │ #1 NewHomeChatState.record (package:wateringtogether/screens/Chat/NewHomeChat.dart:1047:10) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:---> startRecorder flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder._startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:614:13) flutter: │ #1 FlutterSoundRecorder.startRecorder. (package:flutter_sound/public/flutter_sound_recorder.dart:592:13) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:---> _startRecorder. flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.startRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:234:13) flutter: │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:74:22) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 ---> startRecorderCompleted: true flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.startRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:243:13) flutter: │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:74:22) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 <--- startRecorderCompleted: true flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder._startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:689:13) flutter: │ #1 flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:<--- _startRecorder. flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.startRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:602:13) flutter: │ #1 flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:<--- startRecorder flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.setSubscriptionDuration (package:flutter_sound/public/flutter_sound_recorder.dart:516:13) flutter: │ #1 NewHomeChatState.record. (package:wateringtogether/screens/Chat/NewHomeChat.dart:1050:24) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:---> setSubscriptionDuration flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.setSubscriptionDuration (package:flutter_sound/public/flutter_sound_recorder.dart:523:13) flutter: │ #1 flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:<--- setSubscriptionDuration flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.stopRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:726:13) flutter: │ #1 NewHomeChatState.stop (package:wateringtogether/screens/Chat/NewHomeChat.dart:1071:33) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:---> stopRecorder flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder._stopRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:736:13) flutter: │ #1 FlutterSoundRecorder.stopRecorder. (package:flutter_sound/public/flutter_sound_recorder.dart:729:17) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:---> _stopRecorder flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder._stop (package:flutter_sound/public/flutter_sound_recorder.dart:694:13) flutter: │ #1 FlutterSoundRecorder._stopRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:748:17) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:---> _stop flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.stopRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:250:13) flutter: │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:80:22) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 ---> stopRecorderCompleted: true flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.stopRecorderCompleted (package:flutter_sound/public/flutter_sound_recorder.dart:262:13) flutter: │ #1 MethodChannelFlutterSoundRecorder.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_recorder.dart:80:22) flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 <---- stopRecorderCompleted: true flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder._stop (package:flutter_sound/public/flutter_sound_recorder.dart:707:13) flutter: │ #1 flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:<--- _stop flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder._stopRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:752:13) flutter: │ #1 flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:<--- _stopRecorder : /Users/dev/Library/Developer/CoreSimulator/Devices/E73756C6-8F6A-445B-B984-DAF354A1E4DC/data/Containers/Data/Application/583CC394-100D-48BF-93F2-C1E8E1C27A11/tmp/recored_audio_1716296928717.mp4 flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: │ #0 FlutterSoundRecorder.stopRecorder (package:flutter_sound/public/flutter_sound_recorder.dart:731:13) flutter: │ #1 flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ flutter: │ 🐛 FS:<--- stopRecorder flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: stopPath /Users/dev/Library/Developer/CoreSimulator/Devices/E73756C6-8F6A-445B-B984-DAF354A1E4DC/data/Containers/Data/Application/583CC394-100D-48BF-93F2-C1E8E1C27A11/tmp/recored_audio_1716296928717.mp4 flutter: Recored audio : File: '/Users/dev/Library/Developer/CoreSimulator/Devices/E73756C6-8F6A-445B-B984-DAF354A1E4DC/data/Containers/Data/Application/583CC394-100D-48BF-93F2-C1E8E1C27A11/tmp/recored_audio_1716296928717.mp4'

neeraj92144 commented 1 month ago

Also , I have already tried putting this

await recorder.setSubscriptionDuration( const Duration(milliseconds: 1000), );

Above the recorder.startRecorder but same result.

also, I am getting the progress of audio using below code, but it do not record then it will not show changes.

StreamBuilder( stream: recorder.onProgress, builder: (context, snapshot) { final duration = snapshot.hasData ? snapshot.data!.duration : Duration.zero; // Calculate minutes and seconds final minutes = duration.inMinutes.remainder(60); final seconds = duration.inSeconds.remainder(60); // Format the duration as mm:ss final formattedDuration = '$minutes:${seconds.toString().padLeft(2, '0')}'; return Text(formattedDuration, style: TextStyle( color: isAudioReady ? Colors.black : AppColors.chatRunningRedAudio, fontSize: 12, fontWeight: FontWeight.w400, height: 1.273, // Adjust line height if needed letterSpacing: 0.65, )); }, ),

neeraj92144 commented 1 month ago

Now can you suggest solutions to above problem, only occuring the ios only, Thanks.

Larpoux commented 1 month ago

It seems that you use an emulator. can you look on the file /Users/dev/Library/Developer/CoreSimulator/Devices/E73756C6-8F6A-445B-B984-DAF354A1E4DC/data/Containers/Data/Application/583CC394-100D-48BF-93F2-C1E8E1C27A11/tmp/recored_audio_1716296928717.mp4 and check the status of this file ? (presence, size, possibility to play it directly from macos, ...)

Larpoux commented 1 month ago

Note : ~/Library on macos is hidden. You must show the hidden files from the Finder if you use the finder.

neeraj92144 commented 1 month ago

Screenshot 2024-05-21 at 6 49 15 PM

All look like this above and open the file , it is not playing.

Also I tired same with app before to open it but it did not play. Also during recording no , progress found in recorder.onProgress

neeraj92144 commented 1 month ago

https://github.com/Canardoux/flutter_sound/assets/26308047/ca4b0ba7-f2a5-4cfe-bdfc-532b4f2706aa

When I kill app app then it do work, but if we come from other screen ( Like after login , this screen ) on this page then it is not. Same code for as above, also android working perfectly.

I have been trying couple of week but did not solved yet.

neeraj92144 commented 1 month ago

Also , I have already tried to use it using latest version of flutter_sound but same thing happening as well.

Larpoux commented 1 month ago

24 bytes is not good. The file is empty. Can you try to set an absolute path instead of a relative path file name during startRecorder (for example a path to the temp dir, using the PathProvider plugin)

Directory tempDir = await getTemporaryDirectory();
filePath = tempDir.path + '/Foo';
startRecorder(....)
Larpoux commented 1 month ago
Directory tempDir = await getTemporaryDirectory();
filePath = tempDir.path + '/Foo';
startRecorder(....)

(sorry)

Larpoux commented 1 month ago

I am surprised that there is not any call to the flutter call back between startRecorder() and stopRecorder(). Your setSubscriptionDuration() is every second. Are you sure that you don’t close the recorder immediately after opening it ?

neeraj92144 commented 1 month ago

Future record() async { // Common.showWaterToast("record",context);

if (!isRecorderReady) return;
// Common.showWaterToast("record2",context);

Directory tempDir = await getTemporaryDirectory();
'${tempDir.path}/Foo';
             print("tempDir ${tempDir}");

setState(() {
  // currentFilePath =
  //     'recored_audio_${DateTime.now().millisecondsSinceEpoch}.mp4';
      currentFilePath = '${tempDir.path.toString()}/recored_audio_${DateTime.now().millisecondsSinceEpoch}.mp4';
});

var _codec = FlutterSound
    .Codec.aacMP4; // Use the Codec enumeration from FlutterSound

             print("currentFilePath ${currentFilePath}");

    if(recorder == null) {
    }

await recorder
    .startRecorder(codec: _codec, toFile: currentFilePath)
    .then((value) async {
  // Common.showWaterToast("record3",context);
    await recorder.setSubscriptionDuration(
      const Duration(milliseconds: 1000),
    );
  // setState(() {});
  Future.delayed(const Duration(milliseconds: 300), () async {
    setState(() {});
  });
});
setState(() { // 2,50,000 // 10 lac 8.75
  audioElementEnable = true;
});

}

I tried this but link that it is generating is

flutter: tempDir Directory: '/Users/dev/Library/Developer/CoreSimulator/Devices/E73756C6-8F6A-445B-B984-DAF354A1E4DC/data/Containers/Data/Application/23D33B01-E4B5-4F22-B012-3B525F34E966/Library/Caches'

flutter: currentFilePath /Users/dev/Library/Developer/CoreSimulator/Devices/E73756C6-8F6A-445B-B984-DAF354A1E4DC/data/Containers/Data/Application/23D33B01-E4B5-4F22-B012-3B525F34E966/Library/Caches/recored_audio_1716299734739.mp4

neeraj92144 commented 1 month ago

Screenshot 2024-05-21 at 7 29 22 PM

But same 24 bytes size file is coming in on above path

Larpoux commented 1 month ago

I am surprised that there is not any call to the flutter call back between startRecorder() and stopRecorder(). Your setSubscriptionDuration() is every second. Are you sure that you don’t close the recorder immediately after opening it ?

neeraj92144 commented 1 month ago
recorder.closeRecorder();

is only there on dispose method only, so only closing on dispose and not anywere in the code

Larpoux commented 1 month ago

This is correct

Larpoux commented 1 month ago

I mean "sopRecorder() just immediately after startRecorder()"

neeraj92144 commented 1 month ago

Now, what can we do here to solve it

Larpoux commented 1 month ago

Just verify that your callback is called each second. You can put a breakpoint in your callback function to be sure

Larpoux commented 1 month ago

This is correct

Larpoux commented 1 month ago

There is clearly a problem if your callback is not called.

If I understand correctly, your app works well with a fresh startup, but not after you do some processing. What do you do during this processing? Does your app go background?

neeraj92144 commented 1 month ago
Larpoux commented 1 month ago

If I understand correctly, your app works well with a fresh startup, but not after you do some processing. What do you do during this processing? Does your app go background?

neeraj92144 commented 1 month ago

If I understand correctly, your app works well with a fresh startup, but not after you do some processing. What do you do during this processing? Does your app go background? Comment - Not doing anything related to background, just normal dart code and design of chat using firebase. At bottom I am having a option of recording the audio like this

https://github.com/Canardoux/flutter_sound/assets/26308047/7deb3576-09bb-4d71-a4d4-ba7034dd7cad

neeraj92144 commented 1 month ago

I am having this project with current to code with latest lib flutter_sound package , do you need it to dig in, to see exact issue? Can I share?

Larpoux commented 1 month ago

I don’t have much time to spend on flutter sound maintenance. Perhaps you can try to check if there is same problem with the example "Simple Recorder Example" which is released with flutter sound.

If the problem occurs, it means that there is something wrong with flutter sound or more probably with what you do on your emulator. If the problem doesn’t occur with the example, it means that there is a problem with your code.

neeraj92144 commented 1 month ago

Can you ping exact path to the Simple Recorder Example,

No, it is not just with simulator , same thing with real device as well.

Larpoux commented 1 month ago

on GitHub

neeraj92144 commented 1 month ago

Thanks alot for everything.

When I added below code in initRecorder then it started working.

final session = await AudioSession.instance; await session.configure(AudioSessionConfiguration( avAudioSessionCategory: Darwin.AVAudioSessionCategory.playAndRecord, avAudioSessionCategoryOptions: AVAudioSessionCategoryOptions.allowBluetooth | AVAudioSessionCategoryOptions.defaultToSpeaker, avAudioSessionMode: AVAudioSessionMode.spokenAudio, avAudioSessionRouteSharingPolicy: AVAudioSessionRouteSharingPolicy.defaultPolicy, avAudioSessionSetActiveOptions: AVAudioSessionSetActiveOptions.none, androidAudioAttributes: const AndroidAudioAttributes( contentType: AndroidAudioContentType.speech, flags: AndroidAudioFlags.none, usage: AndroidAudioUsage.voiceCommunication, ), androidAudioFocusGainType: AndroidAudioFocusGainType.gain, androidWillPauseWhenDucked: true, ));

Larpoux commented 1 month ago

oh, Yea!

Some times ago Flutter Sound tried to manage itself the Audio Session. But several users was not happy because Flutter Sound was incompatible with others Sound Plugins

We decided to remove the Audio Session Management from Flutter Sound and relay it to the AudioSession plugin.

I am glad that you found the problem. I will remember that when others users have also empty records. This is an issue that several users entered sometimes,

Congratulation.