Closed neeraj92144 closed 1 month ago
Is it possible to have the traces?
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.
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.
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
Now can you suggest solutions to above problem, only occuring the ios only, Thanks.
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, ...)
Note : ~/Library on macos is hidden. You must show the hidden files from the Finder if you use the finder.
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
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.
Also , I have already tried to use it using latest version of flutter_sound but same thing happening as well.
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(....)
Directory tempDir = await getTemporaryDirectory();
filePath = tempDir.path + '/Foo';
startRecorder(....)
(sorry)
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 ?
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
But same 24 bytes size file is coming in on above path
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 ?
recorder.closeRecorder();
is only there on dispose method only, so only closing on dispose and not anywere in the code
This is correct
I mean "sopRecorder() just immediately after startRecorder()"
Now, what can we do here to solve it
Just verify that your callback is called each second. You can put a breakpoint in your callback function to be sure
This is correct
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?
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?
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
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?
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.
Can you ping exact path to the Simple Recorder Example,
No, it is not just with simulator , same thing with real device as well.
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, ));
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.
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);
await recorder.setSubscriptionDuration( const Duration(milliseconds: 1000), ); // setState(() {}); Future.delayed(const Duration(milliseconds: 300), () async {
}
Future stop() async { // Common.showWaterToast("stop",context);
}
Please reply fast so I can fix this, right away, Thanks in advance