audioplayers
audioplayers copied to clipboard
How can I play audio in call mode like in whatsapp?
Is it possible? I can't find a way to accomplish that with flutter. Could you help me?
can you describe better what is call mode?
can you describe better what is call mode?
Sure, it's like in WhatsApp. In WhatsApp if you play an audio file it will play it on speakers and if you are using earphones it will play on the earphones, but if you bring your cellphone close to your ears, the audio stop playing on the speakers and start playing like a phone call just into the ear
I see. I think we must provide ways (if not already present) to play sound in all of those modes (speaker, headphone, etc), but maybe detecting whether the user has their phone up their ears or not could be done by another plugin? I assume you can use camera luminosity, accelerometer, mic sounds, or maybe even a combination of several sensors to guess that, and it seems to be a complex task that could be handled by an interesting plugin (not sure if the solution already exists in android/ios as well)
I see. I think we must provide ways (if not already present) to play sound in all of those modes (speaker, headphone, etc), but maybe detecting whether the user has their phone up their ears or not could be done by another plugin? I assume you can use camera luminosity, accelerometer, mic sounds, or maybe even a combination of several sensors to guess that, and it seems to be a complex task that could be handled by an interesting plugin (not sure if the solution already exists in android/ios as well)
I think I didn't get myself clear. I'm not worried about the sensors or those other functionalities because I understand they should be handled by other means, but this plugin works pretty fine by playing audio through speakers if no earphone is connected or through earphone if there's any present. The problem is just that there's no option to make the sound plays through the standard call source. I've made a research and it seems it could be accomplished in android this way:
private AudioManager audioManager;
audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_CALL); //See this part? This is what I'm asking for the plugin
audioManager.setSpeakerphoneOn(false);
Hope you can get it. If not, thank you anyway. I understand such so basic functionality such as audio handling should be provided by google by default and it was not supposed to be necessary a plugin for that. But thank you for your efforts anyway =)
I think we can have a option to set
audioManager.setMode(AudioManager.MODE_IN_CALL);
on the audioplayer on android, and we would need to find the equivalent parameter on iOS. We can just add a boolean to the play method, as long as it doesn't conflict with anything else.
are you willing to help out with a PR to add that feature?
For iOS we can use setCategory
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
Hi @gopalkrishan123! If I understood you correctly so this is the same feature-request
This feature already implemented in Android. So we just need help with iOS implementation
@gopalkrishan123, to calculate distance between cellphone and the ear, you can use this plugin
Have implemented this in #515 and awaiting review.
Hello! Any updates about this?
Seems to be implemented in #515. Feel free to open a new issue, if it's not the case.