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

Fix player audio focus not respecting mute #10275

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ private void onPrepared(final boolean playWhenReady) {

UIs.call(PlayerUi::onPrepared);

if (playWhenReady) {
if (playWhenReady && !isMuted()) {
audioReactor.requestAudioFocus();
}
}
Expand Down Expand Up @@ -1223,6 +1223,11 @@ public void toggleShuffleModeEnabled() {
public void toggleMute() {
final boolean wasMuted = isMuted();
simpleExoPlayer.setVolume(wasMuted ? 1 : 0);
if (wasMuted) {
audioReactor.requestAudioFocus();
} else {
audioReactor.abandonAudioFocus();
}
UIs.call(playerUi -> playerUi.onMuteUnmuteChanged(!wasMuted));
notifyPlaybackUpdateToListeners();
}
Expand Down Expand Up @@ -1620,7 +1625,9 @@ public void play() {
return;
}

audioReactor.requestAudioFocus();
if (!isMuted()) {
audioReactor.requestAudioFocus();
}

if (currentState == STATE_COMPLETED) {
if (playQueue.getIndex() == 0) {
Expand Down
Loading