From 72d1e5131f526362892cc9ad6ac013210481feea Mon Sep 17 00:00:00 2001 From: John Zhen Mo Date: Tue, 8 May 2018 11:24:42 -0700 Subject: [PATCH] -Added skip silence toggle to playback speed control. -Added step size selector to playback speed control. -Added skip silence flag to player intents. -Moved default preset in playback speed control to neutral dialog button, renamed as reset. -Removed nightcore preset from playback speed control. --- .../org/schabi/newpipe/player/BasePlayer.java | 23 ++- .../newpipe/player/MainVideoPlayer.java | 17 +- .../schabi/newpipe/player/PlayerState.java | 15 +- .../newpipe/player/PopupVideoPlayer.java | 1 + .../newpipe/player/ServicePlayerActivity.java | 12 +- .../helper/PlaybackParameterDialog.java | 168 ++++++++++++------ .../schabi/newpipe/util/NavigationHelper.java | 4 +- .../res/layout/dialog_playback_parameter.xml | 70 +++++++- app/src/main/res/values/strings.xml | 7 +- 9 files changed, 236 insertions(+), 81 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 818f01bc0..525f0d258 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -115,6 +115,7 @@ public abstract class BasePlayer implements public static final String REPEAT_MODE = "repeat_mode"; public static final String PLAYBACK_PITCH = "playback_pitch"; public static final String PLAYBACK_SPEED = "playback_speed"; + public static final String PLAYBACK_SKIP_SILENCE = "playback_skip_silence"; public static final String PLAYBACK_QUALITY = "playback_quality"; public static final String PLAY_QUEUE_KEY = "play_queue_key"; public static final String APPEND_ONLY = "append_only"; @@ -235,20 +236,23 @@ public abstract class BasePlayer implements 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, false); // Good to go... - initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, /*playOnInit=*/true); + initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence, + /*playOnInit=*/true); } protected void initPlayback(@NonNull final PlayQueue queue, @Player.RepeatMode final int repeatMode, final float playbackSpeed, final float playbackPitch, + final boolean playbackSkipSilence, final boolean playOnReady) { destroyPlayer(); initPlayer(playOnReady); setRepeatMode(repeatMode); - setPlaybackParameters(playbackSpeed, playbackPitch); + setPlaybackParameters(playbackSpeed, playbackPitch, playbackSkipSilence); playQueue = queue; playQueue.init(); @@ -1162,19 +1166,22 @@ public abstract class BasePlayer implements return getPlaybackParameters().pitch; } + public boolean getPlaybackSkipSilence() { + return getPlaybackParameters().skipSilence; + } + public void setPlaybackSpeed(float speed) { - setPlaybackParameters(speed, getPlaybackPitch()); + setPlaybackParameters(speed, getPlaybackPitch(), getPlaybackSkipSilence()); } public PlaybackParameters getPlaybackParameters() { - final PlaybackParameters defaultParameters = new PlaybackParameters(1f, 1f); - if (simpleExoPlayer == null) return defaultParameters; + if (simpleExoPlayer == null) return PlaybackParameters.DEFAULT; final PlaybackParameters parameters = simpleExoPlayer.getPlaybackParameters(); - return parameters == null ? defaultParameters : parameters; + return parameters == null ? PlaybackParameters.DEFAULT : parameters; } - public void setPlaybackParameters(float speed, float pitch) { - simpleExoPlayer.setPlaybackParameters(new PlaybackParameters(speed, pitch)); + public void setPlaybackParameters(float speed, float pitch, boolean skipSilence) { + simpleExoPlayer.setPlaybackParameters(new PlaybackParameters(speed, pitch, skipSilence)); } public PlayQueue getPlayQueue() { diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index df9f520e9..56c8f8855 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -181,7 +181,7 @@ public final class MainVideoPlayer extends AppCompatActivity playerImpl.setPlaybackQuality(playerState.getPlaybackQuality()); playerImpl.initPlayback(playerState.getPlayQueue(), playerState.getRepeatMode(), playerState.getPlaybackSpeed(), playerState.getPlaybackPitch(), - playerState.wasPlaying()); + playerState.isPlaybackSkipSilence(), playerState.wasPlaying()); } } @@ -210,7 +210,8 @@ public final class MainVideoPlayer extends AppCompatActivity playerImpl.setRecovery(); playerState = new PlayerState(playerImpl.getPlayQueue(), playerImpl.getRepeatMode(), playerImpl.getPlaybackSpeed(), playerImpl.getPlaybackPitch(), - playerImpl.getPlaybackQuality(), playerImpl.isPlaying()); + playerImpl.getPlaybackQuality(), playerImpl.getPlaybackSkipSilence(), + playerImpl.isPlaying()); StateSaver.tryToSave(isChangingConfigurations(), null, outState, this); } @@ -352,8 +353,11 @@ public final class MainVideoPlayer extends AppCompatActivity //////////////////////////////////////////////////////////////////////////// @Override - public void onPlaybackParameterChanged(float playbackTempo, float playbackPitch) { - if (playerImpl != null) playerImpl.setPlaybackParameters(playbackTempo, playbackPitch); + public void onPlaybackParameterChanged(float playbackTempo, float playbackPitch, + boolean playbackSkipSilence) { + if (playerImpl != null) { + playerImpl.setPlaybackParameters(playbackTempo, playbackPitch, playbackSkipSilence); + } } /////////////////////////////////////////////////////////////////////////// @@ -533,6 +537,7 @@ public final class MainVideoPlayer extends AppCompatActivity this.getRepeatMode(), this.getPlaybackSpeed(), this.getPlaybackPitch(), + this.getPlaybackSkipSilence(), this.getPlaybackQuality() ); context.startService(intent); @@ -554,6 +559,7 @@ public final class MainVideoPlayer extends AppCompatActivity this.getRepeatMode(), this.getPlaybackSpeed(), this.getPlaybackPitch(), + this.getPlaybackSkipSilence(), this.getPlaybackQuality() ); context.startService(intent); @@ -649,7 +655,8 @@ public final class MainVideoPlayer extends AppCompatActivity @Override public void onPlaybackSpeedClicked() { - PlaybackParameterDialog.newInstance(getPlaybackSpeed(), getPlaybackPitch()) + PlaybackParameterDialog + .newInstance(getPlaybackSpeed(), getPlaybackPitch(), getPlaybackSkipSilence()) .show(getSupportFragmentManager(), TAG); } diff --git a/app/src/main/java/org/schabi/newpipe/player/PlayerState.java b/app/src/main/java/org/schabi/newpipe/player/PlayerState.java index 8ffcb6b29..359159809 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PlayerState.java +++ b/app/src/main/java/org/schabi/newpipe/player/PlayerState.java @@ -14,21 +14,26 @@ public class PlayerState implements Serializable { private final float playbackSpeed; private final float playbackPitch; @Nullable private final String playbackQuality; + private final boolean playbackSkipSilence; private final boolean wasPlaying; PlayerState(@NonNull final PlayQueue playQueue, final int repeatMode, - final float playbackSpeed, final float playbackPitch, final boolean wasPlaying) { - this(playQueue, repeatMode, playbackSpeed, playbackPitch, null, wasPlaying); + final float playbackSpeed, final float playbackPitch, + final boolean playbackSkipSilence, final boolean wasPlaying) { + this(playQueue, repeatMode, playbackSpeed, playbackPitch, null, + playbackSkipSilence, wasPlaying); } PlayerState(@NonNull final PlayQueue playQueue, final int repeatMode, final float playbackSpeed, final float playbackPitch, - @Nullable final String playbackQuality, final boolean wasPlaying) { + @Nullable final String playbackQuality, final boolean playbackSkipSilence, + final boolean wasPlaying) { this.playQueue = playQueue; this.repeatMode = repeatMode; this.playbackSpeed = playbackSpeed; this.playbackPitch = playbackPitch; this.playbackQuality = playbackQuality; + this.playbackSkipSilence = playbackSkipSilence; this.wasPlaying = wasPlaying; } @@ -62,6 +67,10 @@ public class PlayerState implements Serializable { return playbackQuality; } + public boolean isPlaybackSkipSilence() { + return playbackSkipSilence; + } + public boolean wasPlaying() { return wasPlaying; } diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java index 3aa8d68f3..146175fb0 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -459,6 +459,7 @@ public final class PopupVideoPlayer extends Service { this.getRepeatMode(), this.getPlaybackSpeed(), this.getPlaybackPitch(), + this.getPlaybackSkipSilence(), this.getPlaybackQuality() ); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 7674105e1..b57a710ed 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -187,6 +187,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity this.player.getRepeatMode(), this.player.getPlaybackSpeed(), this.player.getPlaybackPitch(), + this.player.getPlaybackSkipSilence(), null ).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } @@ -466,13 +467,16 @@ public abstract class ServicePlayerActivity extends AppCompatActivity private void openPlaybackParameterDialog() { if (player == null) return; - PlaybackParameterDialog.newInstance(player.getPlaybackSpeed(), - player.getPlaybackPitch()).show(getSupportFragmentManager(), getTag()); + PlaybackParameterDialog.newInstance(player.getPlaybackSpeed(), player.getPlaybackPitch(), + player.getPlaybackSkipSilence()).show(getSupportFragmentManager(), getTag()); } @Override - public void onPlaybackParameterChanged(float playbackTempo, float playbackPitch) { - if (player != null) player.setPlaybackParameters(playbackTempo, playbackPitch); + public void onPlaybackParameterChanged(float playbackTempo, float playbackPitch, + boolean playbackSkipSilence) { + if (player != null) { + player.setPlaybackParameters(playbackTempo, playbackPitch, playbackSkipSilence); + } } //////////////////////////////////////////////////////////////////////////// diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java index 7c7d87791..60e43ff7d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlaybackParameterDialog.java @@ -21,25 +21,24 @@ import static org.schabi.newpipe.player.BasePlayer.DEBUG; public class PlaybackParameterDialog extends DialogFragment { @NonNull private static final String TAG = "PlaybackParameterDialog"; - public static final double MINIMUM_PLAYBACK_VALUE = 0.25f; + // Maximum allowable range in ExoPlayer + public static final double MINIMUM_PLAYBACK_VALUE = 0.10f; public static final double MAXIMUM_PLAYBACK_VALUE = 3.00f; public static final char STEP_UP_SIGN = '+'; public static final char STEP_DOWN_SIGN = '-'; - public static final double PLAYBACK_STEP_VALUE = 0.05f; - - public static final double NIGHTCORE_TEMPO = 1.20f; - public static final double NIGHTCORE_PITCH_LOWER = 1.15f; - public static final double NIGHTCORE_PITCH_UPPER = 1.25f; + public static final double DEFAULT_PLAYBACK_STEP_VALUE = 0.05f; public static final double DEFAULT_TEMPO = 1.00f; public static final double DEFAULT_PITCH = 1.00f; + public static final boolean DEFAULT_SKIP_SILENCE = false; @NonNull private static final String INITIAL_TEMPO_KEY = "initial_tempo_key"; @NonNull private static final String INITIAL_PITCH_KEY = "initial_pitch_key"; public interface Callback { - void onPlaybackParameterChanged(final float playbackTempo, final float playbackPitch); + void onPlaybackParameterChanged(final float playbackTempo, final float playbackPitch, + final boolean playbackSkipSilence); } @Nullable private Callback callback; @@ -50,6 +49,7 @@ public class PlaybackParameterDialog extends DialogFragment { private double initialTempo = DEFAULT_TEMPO; private double initialPitch = DEFAULT_PITCH; + private boolean initialSkipSilence = DEFAULT_SKIP_SILENCE; @Nullable private SeekBar tempoSlider; @Nullable private TextView tempoMinimumText; @@ -65,16 +65,22 @@ public class PlaybackParameterDialog extends DialogFragment { @Nullable private TextView pitchStepDownText; @Nullable private TextView pitchStepUpText; - @Nullable private CheckBox unhookingCheckbox; + @Nullable private TextView stepSizeOnePercentText; + @Nullable private TextView stepSizeFivePercentText; + @Nullable private TextView stepSizeTenPercentText; + @Nullable private TextView stepSizeTwentyFivePercentText; + @Nullable private TextView stepSizeOneHundredPercentText; - @Nullable private TextView nightCorePresetText; - @Nullable private TextView resetPresetText; + @Nullable private CheckBox unhookingCheckbox; + @Nullable private CheckBox skipSilenceCheckbox; public static PlaybackParameterDialog newInstance(final double playbackTempo, - final double playbackPitch) { + final double playbackPitch, + final boolean playbackSkipSilence) { PlaybackParameterDialog dialog = new PlaybackParameterDialog(); dialog.initialTempo = playbackTempo; dialog.initialPitch = playbackPitch; + dialog.initialSkipSilence = playbackSkipSilence; return dialog; } @@ -123,7 +129,9 @@ public class PlaybackParameterDialog extends DialogFragment { .setView(view) .setCancelable(true) .setNegativeButton(R.string.cancel, (dialogInterface, i) -> - setPlaybackParameters(initialTempo, initialPitch)) + setPlaybackParameters(initialTempo, initialPitch, initialSkipSilence)) + .setNeutralButton(R.string.playback_reset, (dialogInterface, i) -> + setPlaybackParameters(DEFAULT_TEMPO, DEFAULT_PITCH, DEFAULT_SKIP_SILENCE)) .setPositiveButton(R.string.finish, (dialogInterface, i) -> setCurrentPlaybackParameters()); @@ -136,9 +144,13 @@ public class PlaybackParameterDialog extends DialogFragment { private void setupControlViews(@NonNull View rootView) { setupHookingControl(rootView); + setupSkipSilenceControl(rootView); + setupTempoControl(rootView); setupPitchControl(rootView); - setupPresetControl(rootView); + setupStepSize(DEFAULT_PLAYBACK_STEP_VALUE); + + setupStepSizeSelector(rootView); } private void setupTempoControl(@NonNull View rootView) { @@ -157,17 +169,17 @@ public class PlaybackParameterDialog extends DialogFragment { tempoMinimumText.setText(PlayerHelper.formatSpeed(MINIMUM_PLAYBACK_VALUE)); if (tempoStepUpText != null) { - tempoStepUpText.setText(getStepUpPercentString(PLAYBACK_STEP_VALUE)); + tempoStepUpText.setText(getStepUpPercentString(DEFAULT_PLAYBACK_STEP_VALUE)); tempoStepUpText.setOnClickListener(view -> { - onTempoSliderUpdated(getCurrentTempo() + PLAYBACK_STEP_VALUE); + onTempoSliderUpdated(getCurrentTempo() + DEFAULT_PLAYBACK_STEP_VALUE); setCurrentPlaybackParameters(); }); } if (tempoStepDownText != null) { - tempoStepDownText.setText(getStepDownPercentString(PLAYBACK_STEP_VALUE)); + tempoStepDownText.setText(getStepDownPercentString(DEFAULT_PLAYBACK_STEP_VALUE)); tempoStepDownText.setOnClickListener(view -> { - onTempoSliderUpdated(getCurrentTempo() - PLAYBACK_STEP_VALUE); + onTempoSliderUpdated(getCurrentTempo() - DEFAULT_PLAYBACK_STEP_VALUE); setCurrentPlaybackParameters(); }); } @@ -194,22 +206,6 @@ public class PlaybackParameterDialog extends DialogFragment { if (pitchMinimumText != null) pitchMinimumText.setText(PlayerHelper.formatPitch(MINIMUM_PLAYBACK_VALUE)); - if (pitchStepUpText != null) { - pitchStepUpText.setText(getStepUpPercentString(PLAYBACK_STEP_VALUE)); - pitchStepUpText.setOnClickListener(view -> { - onPitchSliderUpdated(getCurrentPitch() + PLAYBACK_STEP_VALUE); - setCurrentPlaybackParameters(); - }); - } - - if (pitchStepDownText != null) { - pitchStepDownText.setText(getStepDownPercentString(PLAYBACK_STEP_VALUE)); - pitchStepDownText.setOnClickListener(view -> { - onPitchSliderUpdated(getCurrentPitch() - PLAYBACK_STEP_VALUE); - setCurrentPlaybackParameters(); - }); - } - if (pitchSlider != null) { pitchSlider.setMax(strategy.progressOf(MAXIMUM_PLAYBACK_VALUE)); pitchSlider.setProgress(strategy.progressOf(initialPitch)); @@ -231,24 +227,84 @@ public class PlaybackParameterDialog extends DialogFragment { } } - private void setupPresetControl(@NonNull View rootView) { - nightCorePresetText = rootView.findViewById(R.id.presetNightcore); - if (nightCorePresetText != null) { - nightCorePresetText.setOnClickListener(view -> { - final double randomPitch = NIGHTCORE_PITCH_LOWER + - Math.random() * (NIGHTCORE_PITCH_UPPER - NIGHTCORE_PITCH_LOWER); + private void setupSkipSilenceControl(@NonNull View rootView) { + skipSilenceCheckbox = rootView.findViewById(R.id.skipSilenceCheckbox); + if (skipSilenceCheckbox != null) { + skipSilenceCheckbox.setChecked(initialSkipSilence); + skipSilenceCheckbox.setOnCheckedChangeListener((compoundButton, isChecked) -> + setCurrentPlaybackParameters()); + } + } - setTempoSlider(NIGHTCORE_TEMPO); - setPitchSlider(randomPitch); + private void setupStepSizeSelector(@NonNull final View rootView) { + stepSizeOnePercentText = rootView.findViewById(R.id.stepSizeOnePercent); + stepSizeFivePercentText = rootView.findViewById(R.id.stepSizeFivePercent); + stepSizeTenPercentText = rootView.findViewById(R.id.stepSizeTenPercent); + stepSizeTwentyFivePercentText = rootView.findViewById(R.id.stepSizeTwentyFivePercent); + stepSizeOneHundredPercentText = rootView.findViewById(R.id.stepSizeOneHundredPercent); + + if (stepSizeOnePercentText != null) { + final double onePercent = 0.01f; + stepSizeOnePercentText.setText(getPercentString(onePercent)); + stepSizeOnePercentText.setOnClickListener(view -> setupStepSize(onePercent)); + } + + if (stepSizeFivePercentText != null) { + final double fivePercent = 0.05f; + stepSizeFivePercentText.setText(getPercentString(fivePercent)); + stepSizeFivePercentText.setOnClickListener(view -> setupStepSize(fivePercent)); + } + + if (stepSizeTenPercentText != null) { + final double tenPercent = 0.10f; + stepSizeTenPercentText.setText(getPercentString(tenPercent)); + stepSizeTenPercentText.setOnClickListener(view -> setupStepSize(tenPercent)); + } + + if (stepSizeTwentyFivePercentText != null) { + final double twentyFivePercent = 0.25f; + stepSizeTwentyFivePercentText.setText(getPercentString(twentyFivePercent)); + stepSizeTwentyFivePercentText.setOnClickListener(view -> + setupStepSize(twentyFivePercent)); + } + + if (stepSizeOneHundredPercentText != null) { + final double oneHundredPercent = 1.00f; + stepSizeOneHundredPercentText.setText(getPercentString(oneHundredPercent)); + stepSizeOneHundredPercentText.setOnClickListener(view -> + setupStepSize(oneHundredPercent)); + } + } + + private void setupStepSize(final double stepSize) { + if (tempoStepUpText != null) { + tempoStepUpText.setText(getStepUpPercentString(stepSize)); + tempoStepUpText.setOnClickListener(view -> { + onTempoSliderUpdated(getCurrentTempo() + stepSize); setCurrentPlaybackParameters(); }); } - resetPresetText = rootView.findViewById(R.id.presetReset); - if (resetPresetText != null) { - resetPresetText.setOnClickListener(view -> { - setTempoSlider(DEFAULT_TEMPO); - setPitchSlider(DEFAULT_PITCH); + if (tempoStepDownText != null) { + tempoStepDownText.setText(getStepDownPercentString(stepSize)); + tempoStepDownText.setOnClickListener(view -> { + onTempoSliderUpdated(getCurrentTempo() - stepSize); + setCurrentPlaybackParameters(); + }); + } + + if (pitchStepUpText != null) { + pitchStepUpText.setText(getStepUpPercentString(stepSize)); + pitchStepUpText.setOnClickListener(view -> { + onPitchSliderUpdated(getCurrentPitch() + stepSize); + setCurrentPlaybackParameters(); + }); + } + + if (pitchStepDownText != null) { + pitchStepDownText.setText(getStepDownPercentString(stepSize)); + pitchStepDownText.setOnClickListener(view -> { + onPitchSliderUpdated(getCurrentPitch() - stepSize); setCurrentPlaybackParameters(); }); } @@ -342,10 +398,11 @@ public class PlaybackParameterDialog extends DialogFragment { //////////////////////////////////////////////////////////////////////////*/ private void setCurrentPlaybackParameters() { - setPlaybackParameters(getCurrentTempo(), getCurrentPitch()); + setPlaybackParameters(getCurrentTempo(), getCurrentPitch(), getCurrentSkipSilence()); } - private void setPlaybackParameters(final double tempo, final double pitch) { + private void setPlaybackParameters(final double tempo, final double pitch, + final boolean skipSilence) { if (callback != null && tempoCurrentText != null && pitchCurrentText != null) { if (DEBUG) Log.d(TAG, "Setting playback parameters to " + "tempo=[" + tempo + "], " + @@ -353,7 +410,7 @@ public class PlaybackParameterDialog extends DialogFragment { tempoCurrentText.setText(PlayerHelper.formatSpeed(tempo)); pitchCurrentText.setText(PlayerHelper.formatPitch(pitch)); - callback.onPlaybackParameterChanged((float) tempo, (float) pitch); + callback.onPlaybackParameterChanged((float) tempo, (float) pitch, skipSilence); } } @@ -367,13 +424,22 @@ public class PlaybackParameterDialog extends DialogFragment { pitchSlider.getProgress()); } + private boolean getCurrentSkipSilence() { + return skipSilenceCheckbox != null && skipSilenceCheckbox.isChecked(); + } + @NonNull private static String getStepUpPercentString(final double percent) { - return STEP_UP_SIGN + PlayerHelper.formatPitch(percent); + return STEP_UP_SIGN + getPercentString(percent); } @NonNull private static String getStepDownPercentString(final double percent) { - return STEP_DOWN_SIGN + PlayerHelper.formatPitch(percent); + return STEP_DOWN_SIGN + getPercentString(percent); + } + + @NonNull + private static String getPercentString(final double percent) { + return PlayerHelper.formatPitch(percent); } } 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 ebbeb06f8..12f6856de 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -100,11 +100,13 @@ public class NavigationHelper { final int repeatMode, final float playbackSpeed, final float playbackPitch, + final boolean playbackSkipSilence, @Nullable final String playbackQuality) { return getPlayerIntent(context, targetClazz, playQueue, playbackQuality) .putExtra(BasePlayer.REPEAT_MODE, repeatMode) .putExtra(BasePlayer.PLAYBACK_SPEED, playbackSpeed) - .putExtra(BasePlayer.PLAYBACK_PITCH, playbackPitch); + .putExtra(BasePlayer.PLAYBACK_PITCH, playbackPitch) + .putExtra(BasePlayer.PLAYBACK_SKIP_SILENCE, playbackSkipSilence); } public static void playOnMainPlayer(final Context context, final PlayQueue queue) { diff --git a/app/src/main/res/layout/dialog_playback_parameter.xml b/app/src/main/res/layout/dialog_playback_parameter.xml index a8c6a5dcd..47937e882 100644 --- a/app/src/main/res/layout/dialog_playback_parameter.xml +++ b/app/src/main/res/layout/dialog_playback_parameter.xml @@ -279,30 +279,88 @@ android:layout_centerHorizontal="true" android:layout_below="@id/separatorCheckbox"/> + + + android:layout_below="@id/skipSilenceCheckbox"> + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5ca88bd6f..8686d21d3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -479,9 +479,10 @@ Playback Speed Controls Tempo Pitch - Unhook (may cause distortion) - Nightcore - Default + Unlink (may cause distortion) + Fast-forward during silence + Step + Reset In order to comply with the European General Data Protection Regulation (GDPR), we herby draw your attention to NewPipe\'s privacy policy. Please read it carefully.\nYou must accept it to send us the bug report.