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

Android: creating file but not recording #34

Closed
haideraltahan opened this issue Jan 23, 2019 · 6 comments
Closed

Android: creating file but not recording #34

haideraltahan opened this issue Jan 23, 2019 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@haideraltahan
Copy link
Contributor

Version of flutter_sound

1.2.4

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.1 18B75, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[✓] Connected device (1 available)
• No issues found!

Platforms you faced the error (IOS or Android or both?)

Android

Expected behavior

Record audio and save to the file.

Actual behavior

When startRecorder is called with or without a fileName, the audio is not saved on the file.
That is the file size is always 8.65KB.

Tested environment (Emulator? Real Device?)

Emulator

@haideraltahan
Copy link
Contributor Author

After further investigation. It does record but with very poor quality... 8kHz is the max frequency. How do I increase the quality?

@hyochan hyochan added help wanted Extra attention is needed android and removed android labels Jan 24, 2019
@hyochan
Copy link
Collaborator

hyochan commented Jan 24, 2019

@haideraltahan Hi. I think you are talking about ios am I right? I've recently decreased the recorded file in ios because of #26. Currently, you should change the value AVAudioQualityMin in ios to AVAudioQualityMax because this variable isn't exposed to dart. See the line.

I would be happy if you can give a nice PR that also manages android side.

@haideraltahan
Copy link
Contributor Author

I was talking about Android as it was very bad quality for my use case.
I solved it by using those settings:

this.model.setMediaRecorder(new MediaRecorder());
this.model.getMediaRecorder().setAudioSource(MediaRecorder.AudioSource.MIC);
this.model.getMediaRecorder().setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
this.model.getMediaRecorder().setAudioEncoder(MediaRecorder.AudioEncoder.AAC_ELD);
this.model.getMediaRecorder().setAudioEncodingBitRate(256000);
this.model.getMediaRecorder().setAudioChannels(numChannels);
this.model.getMediaRecorder().setAudioSamplingRate(sampleRate);
this.model.getMediaRecorder().setOutputFile(path);

@hyochan hyochan added android and removed ios labels Jan 25, 2019
@hyochan
Copy link
Collaborator

hyochan commented Jan 25, 2019

@haideraltahan Thanks for confirming. I hope you to give us PR for this if you'd like to share your work.

@mike-gallego
Copy link
Contributor

@haideraltahan Did you ever resolve this issue? I tried setting those settings in my project but it seemed there was no effect. I even put encoding bit rate 0 and numChannels to 0 and nothing change; same result.

@haideraltahan
Copy link
Contributor Author

@mikeyyg96 try transferring the recording and listening to them. The recording file size alone is not enough to see if it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants