Skip to content

Commit

Permalink
Made audio-focus calls respect mute state.
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Stutzmann committed Aug 3, 2023
1 parent bc4f0c6 commit c06d61a
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 c06d61a

Please sign in to comment.