Files
zarzet d539963762 fix(android): leave the mixed output effect off on a USB output
On Nothing phones the forced DynamicsProcessing effect owns the volume
of the player it is attached to. With a USB DAC every track change left
the song at full volume until a pause and resume (issue 864). USB output
is not offloaded, so the effect has nothing to do there.
2026-11-15 17:48:55 +07:00
..

AudioPlayers


audioplayers_android

The Android implementation of audioplayers.

Mornye local changes

Player commands and native callbacks run on one owned playback Looper, so a slow MediaPlayer reset/release cannot hold Android's input thread. Flutter channel registration and events still run on the main thread. Engine detach queues cleanup without waiting for the media service.

In addition to preserving granted proxy file descriptors, this fork exposes a player-specific setEqualizer method. On Android 9+, DynamicsProcessing attaches to that player's nonzero audio session and provides graphic EQ, preamp, balance, compression and limiting. Effects are released with the underlying player and restored by the playback deck after source preparation. Unsupported effects are reported to the editor without stopping playback. Direct USB and exclusive bit-perfect paths bypass these effects.

API reference: https://developer.android.com/reference/android/media/audiofx/DynamicsProcessing

A setNextPlayer method links a prepared player to start the moment another completes, through MediaPlayer.setNextMediaPlayer, for gapless playback.

A setSpatialAudio method chooses the spatialization behavior of a player's audio attributes on Android 12L+: auto (the default) or never. It applies from the player's next source.

A setPitch method shifts a player's pitch by semitones and lets it follow the playback rate or stay put, on Android 6+. It applies to the current and every later source.

While a player plays on Android 9+, an effect with no processing in use stays enabled on its session, so the platform mixes its audio instead of sending it to a compressed offload output. System features that read the mixed output, such as music-synced phone lights, then receive the music.

Usage

This package is endorsed, which means you can simply use audioplayers normally. This package will be automatically included in your app when you do, so you do not need to add it to your pubspec.yaml.