Added option to resume on audio focus regain. (#624)
This commit is contained in:
parent
10c4f7b465
commit
becc90409f
4 changed files with 22 additions and 1 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue