Feat: Type-safe configureAVAudioSession function that ensures compatibility with AVAudioSessionModes#52
Closed
ChristopherGabba wants to merge 1 commit intohirbod:mainfrom
Conversation
…ility with AVAudioSessionModes
Author
|
@hirbod I also just noticed my logic is a little flawed. I used: if(!isAndroid) {
await Promise.all([VolumeManagerNativeModule.setCategory(category, mixWithOthers), VolumeManagerNativeModule.setMode(mode)]);
}and I think it should be: if(!isAndroid) {
await VolumeManagerNativeModule.setCategory(category, mixWithOthers)
await VolumeManagerNativeModule.setMode(mode)
}Maybe you don't want to fire these methods simultaneously, but sequentially instead... |
Author
|
CLOSING THIS PR, SUPERCEDED BY #53 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@hirbod This is my first time contributing to open-source... like ever. So please feel free to crush my soul on how I did all of this.
The gist of it is, after reading all the docs: https://developer.apple.com/documentation/avfaudio/avaudiosession, it became clear that each
AVAudioSessionCategorycould only be used with specificAVAudioSessionModes. I was pretty thorough in making sure that I have the compatible modes with each category.In order to make this type-safe, I needed to combine them into one function. I also used this to change the types of
AVAudioSessionModeandAVAudioSessionCategoryto anenumtype so that could properly get good developer experience tool tips when mousing over each category.An example of this new function would be:
I also marked the
setCategoryfunction and thesetModefunction as deprecated using this new API.Among other changes, it would appear that the previously had
Alarmcategory is no longer listed, and theAudioProcessingcategory is listed as deprecated. https://developer.apple.com/documentation/avfaudio/avaudiosession/category-swift.structSo I removed the
Alarmoption and flagged theAudioProcessingas deprecated.Now, one last comment. You'll note here: https://developer.apple.com/documentation/avfaudio/avaudiosession/setcategory(_:mode:policy:options:)
That setting this

AVAudioSessionCategoryalso presents more options like options and policy.I think it would be fantastic to add these to the API for further configuration. Additionally I noticed while studying
react-native-vision-cameraAudio Session setup he has this code:I am not sure how we handle this in the
volume-managerpackage, but may be other things to include as options?Maybe a final API would look like this??:
Anyway, thanks again!!