Adding configuration setting and supporting code to pause playback on back button. (#167)
This commit is contained in:
parent
8af61b9086
commit
1c5b3d881c
|
@ -199,4 +199,16 @@ public class VideoPlayActivity extends AppCompatActivity {
|
||||||
Log.v(TAG, "onStart()...");
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,6 +251,10 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL
|
||||||
torrentStream.stopStream();
|
torrentStream.stopStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void pauseVideo() {
|
||||||
|
mService.player.setPlayWhenReady(false);
|
||||||
|
}
|
||||||
|
|
||||||
public void stopVideo() {
|
public void stopVideo() {
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,9 @@
|
||||||
<string name="pref_title_peertube_server">PeerTube Server</string>
|
<string name="pref_title_peertube_server">PeerTube Server</string>
|
||||||
<string name="pref_title_background_play">Background Playback</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_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 -->
|
<!-- languages -->
|
||||||
<string name="ab">Abkhazian</string>
|
<string name="ab">Abkhazian</string>
|
||||||
<string name="aa">Afar</string>
|
<string name="aa">Afar</string>
|
||||||
|
|
|
@ -24,6 +24,12 @@
|
||||||
android:summary="@string/pref_description_language"
|
android:summary="@string/pref_description_language"
|
||||||
android:title="@string/pref_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
|
<ListPreference
|
||||||
android:title="@string/pref_title_app_theme"
|
android:title="@string/pref_title_app_theme"
|
||||||
android:summary="@string/pref_description_app_theme"
|
android:summary="@string/pref_description_app_theme"
|
||||||
|
|
Loading…
Reference in New Issue