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

Fixed Exoplayer doesn't work with mute=true #1696 #1699

Merged
merged 1 commit into from
Sep 21, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class ReactExoplayerView extends FrameLayout implements
private boolean isInBackground;
private boolean isPaused;
private boolean isBuffering;
private boolean muted = false;
private float rate = 1f;
private float audioVolume = 1f;
private int minLoadRetryCount = 3;
Expand Down Expand Up @@ -576,10 +577,14 @@ public void onAudioFocusChange(int focusChange) {
if (player != null) {
if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
// Lower the volume
player.setVolume(audioVolume * 0.8f);
if (!muted) {
player.setVolume(audioVolume * 0.8f);
}
} else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) {
// Raise it back to normal
player.setVolume(audioVolume * 1);
if (!muted) {
player.setVolume(audioVolume * 1);
}
}
}
}
Expand Down Expand Up @@ -912,6 +917,7 @@ public void setResizeModeModifier(@ResizeMode.Mode int resizeMode) {

private void applyModifiers() {
setRepeatModifier(repeat);
setMutedModifier(muted);
}

public void setRepeatModifier(boolean repeat) {
Expand Down Expand Up @@ -1069,6 +1075,7 @@ public void setPausedModifier(boolean paused) {
}

public void setMutedModifier(boolean muted) {
this.muted = muted;
audioVolume = muted ? 0.f : 1.f;
if (player != null) {
player.setVolume(audioVolume);
Expand Down