Skip to content

Fix audio ducking issue by using Android's automatic audio focus management#13169

Open
eubnara wants to merge 2 commits intoTeamNewPipe:devfrom
eubnara:fix-audio-ducking
Open

Fix audio ducking issue by using Android's automatic audio focus management#13169
eubnara wants to merge 2 commits intoTeamNewPipe:devfrom
eubnara:fix-audio-ducking

Conversation

@eubnara
Copy link
Copy Markdown

@eubnara eubnara commented Feb 1, 2026

What is it?

  • Bugfix (user facing)
  • Feature (user facing) ⚠️ Your PR must target the refactor branch
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

Fix audio ducking issue by using Android's automatic audio focus management

Previously, manual audio focus handling caused volume to not be restored after transient ducking on some devices.

This change removes manual AudioFocusRequest management and relies on ExoPlayer's built-in audio focus handling (handleAudioFocus=true), which properly manages automatic ducking as recommended in: https://developer.android.com/media/optimize/audio-focus#automatic-ducking Fixes #9710

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

  • I read the contribution guidelines.
  • The proposed changes follow the AI policy.
  • I tested the changes using an emulator or a physical device.
    • I tested with my phone.

@github-actions github-actions bot added the size/medium PRs with less than 250 changed lines label Feb 1, 2026
@TobiGr TobiGr added bug Issue is related to a bug player Issues related to any player (main, popup and background) labels Feb 1, 2026
@TobiGr TobiGr added this to v0.28.x Feb 3, 2026
@github-project-automation github-project-automation bot moved this to Todo in v0.28.x Feb 3, 2026
@ShareASmile ShareASmile moved this from Todo to In Progress in v0.28.x Feb 7, 2026
…gement

Previously, manual audio focus handling caused volume to not be restored after transient ducking on some devices.

This change removes manual AudioFocusRequest management and relies on ExoPlayer's built-in audio focus handling (handleAudioFocus=true), which properly manages automatic ducking as recommended in: https://developer.android.com/media/optimize/audio-focus#automatic-ducking
Fixes TeamNewPipe#9710
@simonai1254
Copy link
Copy Markdown

Successfully tested on a Samsung Galaxy S25 Ultra with Android 16 / OneUI 8.0;
Audio Ducking now restores to the correct volume after returning to focus.

@Yann-P
Copy link
Copy Markdown

Yann-P commented Mar 11, 2026

Thank you!

Copy link
Copy Markdown
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

Copy link
Copy Markdown
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR breaks the mute option in the main player.
Play a video in NewPipe and use mute. Open a different app and play audio. I do not think that this is the correct approach. We need to fix this differently and keep the manual audio focus management.

Comment on lines -1344 to -1348
if (wasMuted) {
audioReactor.requestAudioFocus();
} else {
audioReactor.abandonAudioFocus();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change breaks the mute functionality. IT is not possible anymore to play audio in a different app and watch a video simultaneously.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reply. I'll figure it out.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TobiGr
I fixed it. Could you review it again please?
Thanks!!

@JayX83

This comment was marked as outdated.

It should play video with mute on even though another app is playing audio.
@simonai1254
Copy link
Copy Markdown

Successfully tested the new/fixed build on a Samsung Galaxy S25 Ultra with Android 16 / OneUI 8.0;
Audio Ducking now restores (pauses and resumes) to the correct volume after returning to focus, or keeps playing if muted in the player before switching apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue is related to a bug player Issues related to any player (main, popup and background) size/medium PRs with less than 250 changed lines

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Issue with volume after interruption

6 participants