-
Notifications
You must be signed in to change notification settings - Fork 553
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
Comments
Is it possible to have the traces? |
Yes, sure, Below is logs , have a look flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── |
Also , I have already tried putting this await recorder.setSubscriptionDuration( 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>( |
Now can you suggest solutions to above problem, only occuring the ios only, Thanks. |
It seems that you use an emulator. |
Note : ~/Library on macos is hidden. You must show the hidden files from the Finder if you use the finder. |
Screen.Recording.2024-05-21.at.6.55.57.PM.movWhen 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(). |
Future record() async {
} 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 |
I am surprised that there is not any call to the flutter call back between startRecorder() and stopRecorder(). |
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? Screen.Recording.2024-05-21.at.6.55.57.PM.mov |
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. If the problem occurs, it means that there is something wrong with flutter sound or more probably with what you do on your emulator. |
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; |
oh, Yea! Some times ago Flutter Sound tried to manage itself the Audio Session. 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. 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
The text was updated successfully, but these errors were encountered: