-
Notifications
You must be signed in to change notification settings - Fork 845
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
iOS volume very low (sound is coming from earpiece) #1194
Comments
It's not the volume. I figured out that it's not playing out of the speaker properly like it's supposed to. Instead it's playing out of the earpiece. I tried setting the audio context like this
But it did not work on iOS. Still playing out of the earpiece. Be careful bringing up the volume too much to compensate out of the earpiece and get a "speakerphone" effect as you may be overdriving the earpiece speaker. Any ideers? |
Yes, you're right,it's really not playing out of the speaker。I turned the volume all the way up and the sound is still very low on ios。 |
Hi , here same bug. The sound play into Ear speaker and won’t play in Bluetooth airpods and sound very low. |
same issue on iOS 15.4.1. |
I ran into the same issue. This is what I did to solve. I created AudioContext for iOS with defaultToSpeaker: false and set it in AudioPlayer.global.setGlobalAudioContext(_getAudioContext()). That solved my audio super quiet issue on my iPhone Xs Max. |
I switched to just_audio already but this looks like the correct solution here. |
@DSoe it's unclear how @AldanisVigo can you please paste the working example of using |
Ok, so this code worked for me: final AudioContext audioContext = AudioContext(
iOS: AudioContextIOS(
defaultToSpeaker: true,
category: AVAudioSessionCategory.ambient,
options: [
AVAudioSessionOptions.defaultToSpeaker,
AVAudioSessionOptions.mixWithOthers,
],
),
android: AudioContextAndroid(
isSpeakerphoneOn: true,
stayAwake: true,
contentType: AndroidContentType.sonification,
usageType: AndroidUsageType.assistanceSonification,
audioFocus: AndroidAudioFocus.none,
),
);
AudioPlayer.global.setGlobalAudioContext(audioContext); |
Everything else is pretty much the same except for there's no Completion listener, but there is still a duration and position listener so whenerver position == duration it's the same thing as the completion listener if you need it. Hope that helps. |
This is what_getAudioContext() has. AudioContext _getAudioContext() {
return AudioContext(
android: AudioContextAndroid(
isSpeakerphoneOn: false,
stayAwake: true,
contentType: AndroidContentType.music,
usageType: AndroidUsageType.media,
audioFocus: AndroidAudioFocus.gain,
),
iOS: AudioContextIOS(
defaultToSpeaker: false,
category: AVAudioSessionCategory.playback,
options: [AVAudioSessionOptions.mixWithOthers]
+ [AVAudioSessionOptions.allowAirPlay]
+ [AVAudioSessionOptions.allowBluetooth]
+ [AVAudioSessionOptions.allowBluetoothA2DP]
)
);
} Since setting defaultToSpeaker: true works for you, I am thinking setting globalAudioContext somehow fixes the audio volume too low issue on iOS. I am not sure though. |
I just had the same issue in a Flame Game (using FlameAudio) where on my iPhone I couldn't hear anything but it was working fine on my iPad. I was going crazy trying to figure this out. Thought maybe something was wrong with my phone. Tried it on my wife's phone same issue. Ended up needed to add the same info above and now both iPhone and iPad have volume. I tried both AVAudioSessionCategory.ambient and AVAudioSessionCategory.playback and either worked. Pretty sure like others have said the key is AVAudioSessionOptions.defaultToSpeaker
|
|
Not working on all devices how to fix? |
If anyone wants to put up a PR for this it would be greatly appreciated (I don't have any Apple devices to properly test this with). |
Hi! |
Hi @tozu, you're welcome. Just start a Merge Request, if you feeling ready :) |
This works, but |
For anyone who is confused about how to make this work, I added the "AudioPlayer.global.setGlobalAudioContext(AudioContext());" line in my 'init state'. See below: ` void initState() {
}` |
Folks, can you try with the newly released AudioPlayers 4.0.0? |
I checked and after update to 4.0.1 it works perfect. Can be closed |
Hey guys, my issue is similar so I'll write my report/suggestion here. I use sound effects and a microphone at the same time in my app, and I noticed that if I set the category to playAndRecord the audio gets very quiet. It happens no matter what other options I choose, because basically the system wants to duck the audio to let the microphone record sound better. The only way I found to fix it is to fork the lib and change the line which updates the category to: Once I use this mode parameter it gets fine. Is there any way the lib could support my case? Maybe there should be a Dart method to update iOS sound mode? |
Hey @asmodeoux, this is not the same issue, please open a new one for your issue. :) |
still having the same issue : final AudioContext audioContext = const AudioContext(
iOS: AudioContextIOS(
category: AVAudioSessionCategory.playAndRecord,
options: [
// AVAudioSessionOptions.defaultToSpeaker,
AVAudioSessionOptions.allowAirPlay,
AVAudioSessionOptions.allowBluetooth,
AVAudioSessionOptions.allowBluetoothA2DP,
AVAudioSessionOptions.mixWithOthers,
],
),
android: AudioContextAndroid(
isSpeakerphoneOn: true,
stayAwake: true,
contentType: AndroidContentType.music,
usageType: AndroidUsageType.media,
audioFocus: AndroidAudioFocus.gain,
),
); @override
void initState() {
super.initState();
audioPlayer.setAudioContext(audioContext);
} |
If you don't change the AudioContext at all, do you still have the same problem? |
In the beginning I wasn't changing the AudioContext, and yes it was working like that, then I checked GitHub answers here, I tried to change the AudioContext and its still the same. |
@Djihanegh can you post the content of your |
# Description Supersedes #1501 * Introduce `AudioContextConfigRoute` to allow forcing audio to `speaker` or `earpiece` (this can be extended to e.g. bluetooth devices) for both iOS and Android * ios: change default AVAudioSessionCategory from `.playAndRecord` to `.playback` to not play from earpiece as in record mode (see #1194) * ios: remove default `AVAudioSessionOptions.defaultToSpeaker` to allow playing from system default device instead of speaker only (see #1486) * android: change default AudioContextAndroid.isSpeakerphoneOn from `true` to `false` to allow playing from system default device instead of speaker only (see #1486) * ios: remove default `AVAudioSessionOptions.mixWithOthers` to interrupt audio of other apps, like in Android * android: change default AudioContextAndroid.stayAwake from `true` to `false` to not stay awake, like in iOS ## Breaking Change ### Migration instructions |Before|After| |---|---| |`AudioContextAndroid()`|`AudioContextAndroid(isSpeakerphoneOn: true, stayAwake: true)`| |`AudioContextIOS()`|`AudioContextIOS(category: AVAudioSessionCategory.playAndRecord, options: [AVAudioSessionOptions.mixWithOthers, AVAudioSessionOptions.defaultToSpeaker])`| |`AudioContextConfig()`|`AudioContextConfig(route: AudioContextConfigRoute.speaker, stayAwake: true})`| ## Related Issues Closes #1491 Closes #1486 #1194
Hi, I have been following this thread for some time. As soon as I saw that a fix had been merged, I immediately upgraded audioplayers to version 5.0.0. Unfortunately, in the logs, I keep getting the same error for iOS. Regardless of the configuration, it is practically the same every time. The only change is when the My configuration
Error:
Without
And here is my pubspec.lock
|
@MlecznyU if you don't add any custom iOS context at all, do you still get the same problem? |
No, error only occurs when custom context is provided. |
Can't you just change the category from |
I tested all |
Alright, please open a new issue for this, since it is not the same issue as this one. |
final session = await AudioSession.instance; You can use this to make audio comming from Speaker |
Hi @MlecznyU, for me the solution for this error was to just change the category to playAndRecord:
Like This: static AudioContext get getContext => const AudioContext(
iOS: AudioContextIOS(
category: AVAudioSessionCategory.playAndRecord,
options: [
AVAudioSessionOptions.mixWithOthers,
AVAudioSessionOptions.defaultToSpeaker,
],
),
android: AudioContextAndroid(
isSpeakerphoneOn: true,
stayAwake: true,
contentType: AndroidContentType.speech,
usageType: AndroidUsageType.assistanceSonification,
audioFocus: AndroidAudioFocus.gain,
),
); |
According to Apple docs. |
Thanks bro! You SAVED ME! |
I still got the issue on 6.0.0. None of the above solutions work for me. |
@MyisCARRY can you plz open a new issue, where you also share your code to reproduce? This issue has been tackled and probably the error is somewhere else. |
Android device is ok, but volume is very low on ios (xsmax os version: 15.5). I see some same issue, but close with 1.0.0-rc4 fix. now i am use 1.0.1.
The text was updated successfully, but these errors were encountered: