Skip to content

Commit

Permalink
Merge pull request #10275 from J-Stutzmann/fix/audio-focus
Browse files Browse the repository at this point in the history
Fix player audio focus not respecting mute
  • Loading branch information
TobiGr authored Aug 3, 2023
2 parents bc4f0c6 + c06d61a commit 50d7d1b
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit 50d7d1b

Please # to comment.