jfversluis / Plugin.Maui.Audio

Plugin.Maui.Audio provides the ability to play audio inside a .NET MAUI application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iPhone 12 playing back on earpiece speaker and therefore is very quiet.

matthewwren opened this issue · comments

When running on the iPhone 12 the playback volume is very low.

        _audioPlayer = AudioManager.Current.CreatePlayer(filePath);
        _audioPlayer.Play();

Even if I try manually setting the volume to 1 it is still the same low volume.

        _audioPlayer = AudioManager.Current.CreatePlayer(filePath);
        _audioPlayer.Volume = 1;
        _audioPlayer.Play();

If I save the wav file and then play it it is loud.

On further investigation it appears that this is due to the fact that it is using the earpiece speaker at the top of the iPhone rather than the loudspeakers. Is there any way I can configure the audio player to use the loudspeakers?

Didn't hear this before (no pun intended), I think the iPhone automatically switches between those devices depending on how you hold the device? Or some other configuration maybe?

Just tried the sample app here and that plays very loud from the regular speakers. Could you maybe try the sample app and see how that behaves?

Yes this is really frustrating and by default the plugin does NOT stream to AirPods, bluetooth devices ect, they also cant be used to record.

There is a simple fix, it seems you need to set the audio category on the audio session. I do this before recording and before playback as I want slightly different settings, but equally it can be done in the iOS AppDelegate once on start-up.

var audioSession = AVAudioSession.SharedInstance(); var err = audioSession.SetCategory(AVAudioSessionCategory.PlayAndRecord, AVAudioSessionCategoryOptions.AllowBluetooth | AVAudioSessionCategoryOptions.AllowBluetooth | AVAudioSessionCategoryOptions.AllowAirPlay | AVAudioSessionCategoryOptions.DefaultToSpeaker); if (err != null) return false; err = audioSession.SetActive(true); if (err != null) return false; return false;

Hope this helps others, would be great to see the library updated to provide more functionality.

Perhaps we could include this information into documentation at the bare minimum

@nathanjeynes Is the final return in your code supposed to be false?

Also, I'm having a hard time getting this into the appdelegate for ios. Do you have anything to show for doing that?