1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-10-31 15:23:00 +00:00

Added option to resume on audio focus regain. (#624)

This commit is contained in:
Tonelico
2017-08-07 06:04:36 -07:00
committed by Mauricio Colli
parent 10c4f7b465
commit becc90409f
4 changed files with 22 additions and 1 deletions

View File

@@ -47,6 +47,8 @@ import com.google.android.exoplayer2.util.Util;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import org.schabi.newpipe.R;
import java.io.File;
import java.text.DecimalFormat;
import java.text.NumberFormat;
@@ -321,10 +323,21 @@ public abstract class BasePlayer implements ExoPlayer.EventListener, AudioManage
}
}
private boolean isResumeAfterAudioFocusGain() {
if (this.sharedPreferences == null || this.context == null) return false;
return this.sharedPreferences.getBoolean(
this.context.getString(R.string.resume_on_audio_focus_gain_key),
false
);
}
protected void onAudioFocusGain() {
if (DEBUG) Log.d(TAG, "onAudioFocusGain() called");
if (simpleExoPlayer != null) simpleExoPlayer.setVolume(DUCK_AUDIO_TO);
animateAudio(DUCK_AUDIO_TO, 1f, DUCK_DURATION);
if (isResumeAfterAudioFocusGain()) simpleExoPlayer.setPlayWhenReady(true);
}
protected void onAudioFocusLoss() {