Adding configuration setting and supporting code to pause playback on back button. (#167)

This commit is contained in:
Don Kimberlin 2020-06-18 23:29:37 -07:00 committed by GitHub
parent 8af61b9086
commit 1c5b3d881c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -251,6 +251,10 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL
torrentStream.stopStream();
}
}
public void pauseVideo() {
mService.player.setPlayWhenReady(false);
}
public void stopVideo() {

View File

@ -60,6 +60,9 @@
<string name="pref_title_peertube_server">PeerTube Server</string>
<string name="pref_title_background_play">Background Playback</string>
<string name="pref_description_background_play">If enabled, continues to play video in background.</string>
<string name="pref_title_back_pause">Pause on back button</string>
<string name="pref_description_back_pause">Pause background play when pressing back during video playback.</string>
<!-- languages -->
<string name="ab">Abkhazian</string>
<string name="aa">Afar</string>

View File

@ -24,6 +24,12 @@
android:summary="@string/pref_description_language"
android:title="@string/pref_language" />
<SwitchPreference
android:defaultValue="true"
android:key="pref_back_pause"
android:summary="@string/pref_description_back_pause"
android:title="@string/pref_title_back_pause" />
<ListPreference
android:title="@string/pref_title_app_theme"
android:summary="@string/pref_description_app_theme"