-
Notifications
You must be signed in to change notification settings - Fork 67
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
On iOS make the AVAudioSession.Category configurable to support the silent switch #22
Comments
Actually, I'm after the opposite—I find on ios that the mute switch does silence NativeAudio.play(), but I'd like to be able to play alert sounds regardless of the switch position. Are you seeing that differently? |
Yes, I'm using |
Interesting—I've tried simple and complex, and find the toggle affects both :). I'm using a .m4a file and this is on an iphone 8 with ios 14.4. |
Interesting, looking at the following line, the app should actually always play the audio based on the category of Playback native-audio/ios/Plugin/Plugin.swift Line 27 in 57b9a8e
See Apple docs: https://developer.apple.com/documentation/avfaudio/avaudiosessioncategoryplayback |
I just tried my app in the iPhone simulator for iPhone 8, and it behaves exactly as you suggest. But on my physical iPhone 8, the silent toggle silences the sounds. I wonder if there is a phone setting involved somewhere as well? |
I made a plugin to allow to detect mute in ios/android and let show to user he will have no sound in mute: https://github.com/riderx/capacitor-mute |
Any news on this? Still struggling to find a solution. |
Is your feature request related to a problem? Please describe.
When playing audio with iOS, users expect for apps to silence the audio when the physical silent switch is toggled off.
This is supported in the API by setting the appropriate category on AVAudioSession.sharedInstance().setCategory which is hardcoded to "playback" in the plugin.
Describe the solution you'd like
Add a configuration parameter for iOS, perhaps in preloadComplex to set the iOS Audio Session category
Describe alternatives you've considered
Remove AVAudioSession.sharedInstance().setCategory from the plugin and let each app set it's own category in AppDelegate.
Additional context
See documentation here: https://developer.apple.com/documentation/avfaudio/avaudiosessioncategory
The text was updated successfully, but these errors were encountered: