From dcd35b038e0abbf1d94e31643bc8d617a04d6e89 Mon Sep 17 00:00:00 2001 From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com> Date: Mon, 21 Oct 2019 15:44:35 +0200 Subject: [PATCH] Adjust BasePlayer to use seek duration of preferences. Changes behaviour when double-tapping in video and clicking fast forward/rewind in background mode. --- .../java/org/schabi/newpipe/player/BasePlayer.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 a07afcea9..97b4e6a92 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -178,7 +178,7 @@ public abstract class BasePlayer implements // Player //////////////////////////////////////////////////////////////////////////*/ - protected final static int FAST_FORWARD_REWIND_AMOUNT_MILLIS = 10000; // 10 Seconds + protected final static String FAST_FORWARD_REWIND_DEFAULT_AMOUNT_MILLIS = "10000"; // 10 seconds protected final static int PLAY_PREV_ACTIVATION_LIMIT_MILLIS = 5000; // 5 seconds protected final static int PROGRESS_LOOP_INTERVAL_MILLIS = 500; protected final static int RECOVERY_SKIP_THRESHOLD_MILLIS = 3000; // 3 seconds @@ -954,12 +954,20 @@ public abstract class BasePlayer implements public void onFastRewind() { if (DEBUG) Log.d(TAG, "onFastRewind() called"); - seekBy(-FAST_FORWARD_REWIND_AMOUNT_MILLIS); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + final String key = context.getString(R.string.seek_duration_key); + final String value = prefs.getString(key, FAST_FORWARD_REWIND_DEFAULT_AMOUNT_MILLIS); + final int duration = Integer.parseInt(value); + seekBy(-duration); } public void onFastForward() { if (DEBUG) Log.d(TAG, "onFastForward() called"); - seekBy(FAST_FORWARD_REWIND_AMOUNT_MILLIS); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + final String key = context.getString(R.string.seek_duration_key); + final String value = prefs.getString(key, FAST_FORWARD_REWIND_DEFAULT_AMOUNT_MILLIS); + final int duration = Integer.parseInt(value); + seekBy(duration); } public void onPlayPrevious() {