jfversluis / Plugin.Maui.Audio

Plugin.Maui.Audio provides the ability to play audio inside a .NET MAUI application
MIT License
261 stars 46 forks source link

Code snippet in Wiki breaks microphone on iOS SetCategory(AVAudioSessionCategory.Playback) #87

Closed rburnashev85 closed 10 months ago

rburnashev85 commented 10 months ago
#if IOS
    AVFoundation.AVAudioSession.SharedInstance().SetCategory(AVAudioSessionCategory.Playback);
#endif

I experienced microphone issues on iOS using Azure speech services after I ran this code snipped.

https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues/2188

bijington commented 10 months ago

Why are you using the above code snippet?

Anyway the issue is because it is changing the overall category for media. You will need to undo this change once you have finished using it for whatever purpose it is. Or find an alternative option from AVAudioSessionCategory.

That being said I would like to investigate how we could provide a mechanism to change values like this easily

rburnashev85 commented 10 months ago

I used it to make audio play in iPhone's silent mode as it is described in your wiki https://github.com/jfversluis/Plugin.Maui.Audio/wiki It would be nice if your library would provide some option to play sound though silent mode. Not breaking microphone of course :-)

bijington commented 10 months ago

For now a workaround would be to keep track of what AVFoundation.AVAudioSession.SharedInstance().Category is before you change it and then set that value back after playing the audio.