Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[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 opened this issue May 21, 2024 · 31 comments

Comments

@neeraj92144
Copy link

neeraj92144 commented May 21, 2024

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

@neeraj92144 neeraj92144 changed the title [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 [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 ) May 21, 2024
@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

Is it possible to have the traces?

@neeraj92144
Copy link
Author

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
Copy link
Author

neeraj92144 commented May 21, 2024

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<FlutterSound.RecordingDisposition>(
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
Copy link
Author

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

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

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
Copy link
Collaborator

Larpoux commented May 21, 2024

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

@neeraj92144
Copy link
Author

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
Copy link
Author

neeraj92144 commented May 21, 2024

Screen.Recording.2024-05-21.at.6.55.57.PM.mov

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
Copy link
Author

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

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

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
Copy link
Collaborator

Larpoux commented May 21, 2024

Directory tempDir = await getTemporaryDirectory();
filePath = tempDir.path + '/Foo';
startRecorder(....)

(sorry)

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

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
Copy link
Author

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
Copy link
Author

neeraj92144 commented May 21, 2024

Screenshot 2024-05-21 at 7 29 22 PM

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

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

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
Copy link
Author

neeraj92144 commented May 21, 2024

recorder.closeRecorder();

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

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

This is correct

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

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

@neeraj92144
Copy link
Author

Now, what can we do here to solve it

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

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

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

This is correct

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

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
Copy link
Author

  • I mean "sopRecorder() just immediately after startRecorder()"
    comment - No not calling it just after the startRecorder but call when I want to stop recording then I call stopRecorder and get the local path of audio , further can play on device.

@Larpoux
Copy link
Collaborator

Larpoux commented May 21, 2024

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
Copy link
Author

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

Screen.Recording.2024-05-21.at.6.55.57.PM.mov

@neeraj92144
Copy link
Author

neeraj92144 commented May 21, 2024

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
Copy link
Collaborator

Larpoux commented May 21, 2024

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
Copy link
Author

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
Copy link
Collaborator

Larpoux commented May 21, 2024

on GitHub

@neeraj92144
Copy link
Author

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
Copy link
Collaborator

Larpoux commented May 21, 2024

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.

@Larpoux Larpoux closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants