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 601fd96bf..ecae13290 100644
--- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java
+++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java
@@ -118,12 +118,6 @@ public abstract class BasePlayer implements
@NonNull
public static final String REPEAT_MODE = "repeat_mode";
@NonNull
- public static final String PLAYBACK_PITCH = "playback_pitch";
- @NonNull
- public static final String PLAYBACK_SPEED = "playback_speed";
- @NonNull
- public static final String PLAYBACK_SKIP_SILENCE = "playback_skip_silence";
- @NonNull
public static final String PLAYBACK_QUALITY = "playback_quality";
@NonNull
public static final String PLAY_QUEUE_KEY = "play_queue_key";
@@ -287,11 +281,12 @@ public abstract class BasePlayer implements
return;
}
+ final PlaybackParameters savedParameters = retrievePlaybackParametersFromPreferences();
+ final float playbackSpeed = savedParameters.speed;
+ final float playbackPitch = savedParameters.pitch;
+ final boolean playbackSkipSilence = savedParameters.skipSilence;
+
final int repeatMode = intent.getIntExtra(REPEAT_MODE, getRepeatMode());
- final float playbackSpeed = intent.getFloatExtra(PLAYBACK_SPEED, getPlaybackSpeed());
- final float playbackPitch = intent.getFloatExtra(PLAYBACK_PITCH, getPlaybackPitch());
- final boolean playbackSkipSilence = intent.getBooleanExtra(PLAYBACK_SKIP_SILENCE,
- getPlaybackSkipSilence());
final boolean isMuted = intent
.getBooleanExtra(IS_MUTED, simpleExoPlayer != null && isMuted());
@@ -330,6 +325,20 @@ public abstract class BasePlayer implements
/*playOnInit=*/!intent.getBooleanExtra(START_PAUSED, false), isMuted);
}
+ private PlaybackParameters retrievePlaybackParametersFromPreferences() {
+ final SharedPreferences preferences =
+ PreferenceManager.getDefaultSharedPreferences(context);
+
+ final float speed = preferences
+ .getFloat(context.getString(R.string.playback_speed_key), getPlaybackSpeed());
+ final float pitch = preferences.getFloat(context.getString(R.string.playback_pitch_key),
+ getPlaybackPitch());
+ final boolean skipSilence = preferences
+ .getBoolean(context.getString(R.string.playback_skip_silence_key),
+ getPlaybackSkipSilence());
+ return new PlaybackParameters(speed, pitch, skipSilence);
+ }
+
protected void initPlayback(@NonNull final PlayQueue queue,
@Player.RepeatMode final int repeatMode,
final float playbackSpeed,
@@ -1470,9 +1479,20 @@ public abstract class BasePlayer implements
public void setPlaybackParameters(final float speed, final float pitch,
final boolean skipSilence) {
+ savePlaybackParametersToPreferences(speed, pitch, skipSilence);
simpleExoPlayer.setPlaybackParameters(new PlaybackParameters(speed, pitch, skipSilence));
}
+ private void savePlaybackParametersToPreferences(final float speed, final float pitch,
+ final boolean skipSilence) {
+ PreferenceManager.getDefaultSharedPreferences(context)
+ .edit()
+ .putFloat(context.getString(R.string.playback_speed_key), speed)
+ .putFloat(context.getString(R.string.playback_pitch_key), pitch)
+ .putBoolean(context.getString(R.string.playback_skip_silence_key), skipSilence)
+ .apply();
+ }
+
public PlayQueue getPlayQueue() {
return playQueue;
}
diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
index 32c062571..ccaa79f98 100644
--- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
+++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java
@@ -120,9 +120,6 @@ public final class NavigationHelper {
final boolean isMuted) {
return getPlayerIntent(context, targetClazz, playQueue, playbackQuality, resumePlayback)
.putExtra(BasePlayer.REPEAT_MODE, repeatMode)
- .putExtra(BasePlayer.PLAYBACK_SPEED, playbackSpeed)
- .putExtra(BasePlayer.PLAYBACK_PITCH, playbackPitch)
- .putExtra(BasePlayer.PLAYBACK_SKIP_SILENCE, playbackSkipSilence)
.putExtra(BasePlayer.START_PAUSED, startPaused)
.putExtra(BasePlayer.IS_MUTED, isMuted);
}
diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml
index 980af0943..b5eeae6aa 100644
--- a/app/src/main/res/values/settings_keys.xml
+++ b/app/src/main/res/values/settings_keys.xml
@@ -177,6 +177,9 @@
enable_playback_resume
enable_playback_state_lists
playback_unhook_key
+ playback_speed_key
+ playback_pitch_key
+ playback_skip_silence_key
app_language_key
enable_lock_screen_video_thumbnail