Skip to content

What AndroidAudioAttributes values to set to ensure instant playback? #170

Description

@ryanheise Thank you very much for providing audio_seesion, just_audio and and audio_service packages!

On some Android devices it happens that audio files are played with a few hundred milliseconds delay. This leads to the effect that short audio files (~1 second) sound as if playback starts in the middle of the file.

Question now is, can this be fixed using AndroidAudioAttributes? If so: What values should be set for AndroidAudioAttributes.contentType and AndroidAudioAttributes.usage? And should AndroidAudioAttributes be set for each AudioPlayer or just at AudioSession?

A few more details:
All AudioPlayer instances are loaded during startup and played on demand by calling:

   await player.seek(Duration.zero);
   player.play();

The delayed audio output happens only on a few devices and even while background audio is looping, making me doubt that it is related to Android warming up the audio pipeline.

I'm unfortunately unable to reproduce the issue, but got quite some bug reports over the past few years, so any advise is welcome,
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions