ryanheise / just_audio

Audio Player
1.03k stars 638 forks source link

Choppy playback with AAC on newer Android Devices #581

Open dhcracchiolo opened 2 years ago

dhcracchiolo commented 2 years ago

Which API doesn't behave as documented, and how does it misbehave? Playback of (some) AAC files sound very choppy. I tried playing these same files with different players and no problem.

Minimal reproduction project The example.

To Reproduce (i.e. user steps, not code) Just try playing this audio file: https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview125/v4/e8/28/29/e828299c-cea7-dd3e-8612-77a632bd60e3/mzaf_7797752939119995161.plus.aac.p.m4a

Error messages

Expected behavior Clear good sounding audio.

Screenshots

Desktop (please complete the following information):

Smartphone (please complete the following information): I have no problem on my old Oneplus 2 but have very poor performance on my new Oneplus 7t.

Flutter SDK version

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.5.0, on Mac OS X 10.15.7 19H1217 darwin-x64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 4.1) [✓] IntelliJ IDEA Community Edition (version 2020.3.1) [✓] VS Code (version 1.61.2) [✓] Connected device (2 available) • No issues found!

Additional context Any ideas?

ryanheise commented 2 years ago

just_audio uses Google's ExoPlayer library on Android. The only option I'm aware of in ExoPlayer that can improve performance is audio offload mode, requested in #522 , but according to ExoPlayer's page, this should only provide any benefit when the screen is off. When the screen is on, performance should be roughly the same with or without audio offload mode.

If you want, you can experiment by forking this repo and editing the code to enable audio offload mode and see if it solves your issue. If it does, please vote for the other issue to increase its priority.

dhcracchiolo commented 2 years ago

Unfortunately I have the problem with the screen on so I don't think that would solve it. I seem to have this problem on all android 11 devices. By a chance is there an easy way to downgrade to the old audio api that runs on the older android devices? I've tried setting the compleSdkVersion and targetSdkVersion to 29 but no dice.

ryanheise commented 2 years ago

Unfortunately I have the problem with the screen on so I don't think that would solve it.

It is still worth a try.

I seem to have this problem on all android 11 devices. By a chance is there an easy way to downgrade to the old audio api that runs on the older android devices? I've tried setting the compleSdkVersion and targetSdkVersion to 29 but no dice.

Since Google wrote both ExoPlayer and Android, you might consider opening an issue with the ExoPlayer project to see if there's a reason for this Android 11-specific problem. First, you would want to download the ExoPlayer example and modify one of the URLs to your own to see if it reproduces the issue.