From 550364906d8755292fb2b2c80b6ac10f89ad6ffc Mon Sep 17 00:00:00 2001 From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com> Date: Mon, 21 Oct 2019 15:40:33 +0200 Subject: [PATCH 1/6] Add new preference for seek duration. Add new ListPreference under settings/ video & audio for the duration of a seek. With options for 5, 10, 15, 20, 25, 30 seconds. --- app/src/main/res/values/settings_keys.xml | 19 +++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/video_audio_settings.xml | 9 +++++++++ 3 files changed, 29 insertions(+) diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 8dcc2ce31..bd924dbdf 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -28,6 +28,25 @@ screen_brightness_key screen_brightness_timestamp_key + seek_duration + 10000 + + 5 seconds + 10 seconds + 15 seconds + 20 seconds + 25 seconds + 30 seconds + + + 5000 + 10000 + 15000 + 20000 + 25000 + 30000 + + minimize_on_exit_key @string/minimize_on_exit_none_key minimize_on_exit_none_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2cdf139df..6cf445b08 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -70,6 +70,7 @@ Remember last size and position of popup Use fast inexact seek Inexact seek allows the player to seek to positions faster with reduced precision + Seek duration Load thumbnails Show comments Disable to stop showing comments diff --git a/app/src/main/res/xml/video_audio_settings.xml b/app/src/main/res/xml/video_audio_settings.xml index 4e1b1f8b2..484457ceb 100644 --- a/app/src/main/res/xml/video_audio_settings.xml +++ b/app/src/main/res/xml/video_audio_settings.xml @@ -146,5 +146,14 @@ android:key="@string/use_inexact_seek_key" android:summary="@string/use_inexact_seek_summary" android:title="@string/use_inexact_seek_title"/> + + 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 2/6] 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() { From 17146c2c1383d0cb11ee4bfdae941ea08a5c8ca0 Mon Sep 17 00:00:00 2001 From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com> Date: Wed, 6 Nov 2019 19:20:48 +0100 Subject: [PATCH 3/6] Rename adjustable seek duration setting Change from "Seek duration" to "Fast-forward/-rewind seek duration" --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6cf445b08..19013322d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -70,7 +70,7 @@ Remember last size and position of popup Use fast inexact seek Inexact seek allows the player to seek to positions faster with reduced precision - Seek duration + Fast-forward/-rewind seek duration Load thumbnails Show comments Disable to stop showing comments From 949c01b37fca9ca3fda8652bf468370e85820cf2 Mon Sep 17 00:00:00 2001 From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com> Date: Mon, 25 Nov 2019 11:16:59 +0100 Subject: [PATCH 4/6] Extract getting of seek duration into a function --- .../java/org/schabi/newpipe/player/BasePlayer.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 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 97b4e6a92..17be0998f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -954,20 +954,21 @@ public abstract class BasePlayer implements public void onFastRewind() { if (DEBUG) Log.d(TAG, "onFastRewind() called"); - 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); + final int duration = getSeekDuration(); seekBy(-duration); } public void onFastForward() { if (DEBUG) Log.d(TAG, "onFastForward() called"); + final int duration = getSeekDuration(); + seekBy(duration); + } + + private int getSeekDuration() { 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); + return Integer.parseInt(value); } public void onPlayPrevious() { From 334437137eaae72cd574acbb47e22abafa16df83 Mon Sep 17 00:00:00 2001 From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com> Date: Mon, 25 Nov 2019 16:30:37 +0100 Subject: [PATCH 5/6] Remove local variable for seek duration --- app/src/main/java/org/schabi/newpipe/player/BasePlayer.java | 6 ++---- 1 file changed, 2 insertions(+), 4 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 17be0998f..f35287648 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -954,14 +954,12 @@ public abstract class BasePlayer implements public void onFastRewind() { if (DEBUG) Log.d(TAG, "onFastRewind() called"); - final int duration = getSeekDuration(); - seekBy(-duration); + seekBy(-getSeekDuration()); } public void onFastForward() { if (DEBUG) Log.d(TAG, "onFastForward() called"); - final int duration = getSeekDuration(); - seekBy(duration); + seekBy(getSeekDuration()); } private int getSeekDuration() { From 8970a663ec59cd743357500acba5d6f7b109fce4 Mon Sep 17 00:00:00 2001 From: Xiang Rong Lin <41164160+XiangRongLin@users.noreply.github.com> Date: Thu, 12 Dec 2019 19:15:15 +0100 Subject: [PATCH 6/6] Rename "seek_duration_default_key" and use it in BasePlayer --- app/src/main/java/org/schabi/newpipe/player/BasePlayer.java | 3 +-- app/src/main/res/values/settings_keys.xml | 2 +- app/src/main/res/xml/video_audio_settings.xml | 2 +- 3 files changed, 3 insertions(+), 4 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 f35287648..6452a9850 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,6 @@ public abstract class BasePlayer implements // Player //////////////////////////////////////////////////////////////////////////*/ - 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 @@ -965,7 +964,7 @@ public abstract class BasePlayer implements private int getSeekDuration() { 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 String value = prefs.getString(key, context.getString(R.string.seek_duration_default_value)); return Integer.parseInt(value); } diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index bd924dbdf..6aaaa0630 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -29,7 +29,7 @@ screen_brightness_timestamp_key seek_duration - 10000 + 10000 5 seconds 10 seconds diff --git a/app/src/main/res/xml/video_audio_settings.xml b/app/src/main/res/xml/video_audio_settings.xml index 484457ceb..0ff43ce90 100644 --- a/app/src/main/res/xml/video_audio_settings.xml +++ b/app/src/main/res/xml/video_audio_settings.xml @@ -149,7 +149,7 @@