diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java
index 10f4feb48..8c2e5c6b8 100644
--- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java
+++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java
@@ -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() {
diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml
index 071592b73..2a1398b09 100644
--- a/app/src/main/res/values/settings_keys.xml
+++ b/app/src/main/res/values/settings_keys.xml
@@ -14,7 +14,7 @@
autoplay_through_intent
use_oldplayer
player_gesture_controls
-
+ resume_on_audio_focus_gain
default_resolution_preference
360p
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a2449e02a..91dc973ef 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -71,6 +71,8 @@
Use gestures to control the brightness and volume of the player
Search suggestions
Show suggestions when searching
+ Resume on focus gain
+ Continue playing after interruptions (e.g. phone calls)
Download
diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml
index 282aba918..a0c358c4d 100644
--- a/app/src/main/res/xml/settings.xml
+++ b/app/src/main/res/xml/settings.xml
@@ -64,6 +64,12 @@
android:summary="@string/player_gesture_controls_summary"
android:title="@string/player_gesture_controls_title"/>
+
+