diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
index 2b69783..3c6c3f5 100644
--- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
+++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java
@@ -199,4 +199,16 @@ public class VideoPlayActivity extends AppCompatActivity {
Log.v(TAG, "onStart()...");
}
+ public void onBackPressed() {
+
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
+ if (sharedPref.getBoolean("pref_back_pause", true)) {
+ VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment)
+ getSupportFragmentManager().findFragmentById(R.id.video_player_fragment);
+ assert videoPlayerFragment != null;
+ videoPlayerFragment.pauseVideo();
+ }
+ Log.v(TAG, "onBackPressed()...");
+ super.onBackPressed();
+ }
}
diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java
index 62e8d24..39e142d 100644
--- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java
+++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java
@@ -251,6 +251,10 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL
torrentStream.stopStream();
}
}
+
+ public void pauseVideo() {
+ mService.player.setPlayWhenReady(false);
+ }
public void stopVideo() {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9cefc3c..ef83c3a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -60,6 +60,9 @@
PeerTube Server
Background Playback
If enabled, continues to play video in background.
+ Pause on back button
+ Pause background play when pressing back during video playback.
+
Abkhazian
Afar
diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml
index 3b1e6a1..a6d4e93 100644
--- a/app/src/main/res/xml/pref_general.xml
+++ b/app/src/main/res/xml/pref_general.xml
@@ -24,6 +24,12 @@
android:summary="@string/pref_description_language"
android:title="@string/pref_language" />
+
+