Skip to content
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

AudioSessionConfiguration with multiple categories causes PlatformException(-50) #127

Open
thedeukalion opened this issue Apr 3, 2024 · 0 comments

Comments

@thedeukalion
Copy link

thedeukalion commented Apr 3, 2024

With this configuration:

const AudioSessionConfiguration(
      avAudioSessionCategory: AVAudioSessionCategory.playback,
      avAudioSessionCategoryOptions: AVAudioSessionCategoryOptions.mixWithOthers
        | AVAudioSessionCategoryOptions.allowBluetoothA2dp 
        | AVAudioSessionCategoryOptions.allowBluetooth,
      avAudioSessionMode: AVAudioSessionMode.defaultMode,
      avAudioSessionRouteSharingPolicy: AVAudioSessionRouteSharingPolicy.defaultPolicy,
      avAudioSessionSetActiveOptions: AVAudioSessionSetActiveOptions.none,
      androidAudioAttributes: AndroidAudioAttributes(
        contentType: AndroidAudioContentType.sonification,
        flags: AndroidAudioFlags.none,
        usage: AndroidAudioUsage.media,
      ),
      androidAudioFocusGainType: AndroidAudioFocusGainType.gain,
      androidWillPauseWhenDucked: false,
)

Will cause error:
PlatformException(-50, The operation couldn’t be completed)

And here is obvious support for flags in AVAudioSessionCategoryOptions:
https://github.com/ryanheise/audio_session/blob/master/lib/src/darwin.dart#L370

And the native code that this probably relates to:
https://developer.apple.com/documentation/avfaudio/avaudiosession/1771734-setcategory
(A mask of additional options for handling audio. For a list of constants, see AVAudioSession.CategoryOptions.)

Either the documentation is not good enough or how can this be a misconfiguration and why is this throwing errors?

Removing the bluetooth configuration makes the configuration work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant