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

feat(android)!: configurable SoundPool and AudioManager.mode #1388

Merged
merged 62 commits into from Jan 21, 2023

Conversation

Gustl22
Copy link
Collaborator

@Gustl22 Gustl22 commented Jan 16, 2023

  • feat(android): configurable SoundPool in LOW_LATENCY mode
  • fix(android): apply global AudioContext to MediaPlayer
  • feat(android): add AudioMode to AudioContextAndroid
  • feat(android): set AudioManager.mode and AudioManager.isSpeakerphoneOn on setGlobalAudioContext
  • docs: add missing docs for audio_context_config library
  • docs: add docs on how to set platform-specific audio context

Description

SoundPool could not be configured with AudioContext attributes. This Merge Request adds the functionality to also configure playing sources in LOW_LATENCY mode.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs:, chore: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation and added dartdoc comments with ///, where necessary.
  • I have updated/added relevant examples in example.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Migration instructions

If you create an AudioPlayer in LOW_LATENCY mode, it's presets are not the same as before as they are taken from the AudioContext now. Nether the less you can set them via:

final audioContext = const AudioContext(
  android: AudioContextAndroid(
    usageType: AndroidUsageType.game,
  ),
),

Set context globally, before creating a player:

AudioPlayer.global.setGlobalAudioContext(audioContext);
final player = AudioPlayer()..setPlayerMode(PlayerMode.lowLatency);

Set context for an existing single player:

player.setPlayerMode(PlayerMode.lowLatency)
player.setAudioContext(audioContext );

Related Issues

Closes #1240
Closes #135

Related:
#1202
#1321
#934

@Gustl22 Gustl22 changed the title feat(android)!: configurable soundpool feat(android)!: configurable SoundPool Jan 16, 2023
@Gustl22 Gustl22 changed the title feat(android)!: configurable SoundPool feat(android)!: configurable SoundPool and AudioManager.mode Jan 21, 2023
@Gustl22 Gustl22 marked this pull request as ready for review January 21, 2023 13:46
@Gustl22
Copy link
Collaborator Author

Gustl22 commented Jan 21, 2023

Consider adding the bullets in the PR description, when squashing.

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

Successfully merging this pull request may close these issues.

earpieceOrSpeakersToggle is missing in the new version of the audioplayers Play sound with alarm stream
2 participants