Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/java/org/schabi/newpipe/player/BasePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1129,13 +1129,15 @@ public void onFastRewind() {
Log.d(TAG, "onFastRewind() called");
}
seekBy(-getSeekDuration());
triggerProgressUpdate();
}

public void onFastForward() {
if (DEBUG) {
Log.d(TAG, "onFastForward() called");
}
seekBy(getSeekDuration());
triggerProgressUpdate();
}

private int getSeekDuration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import java.util.Collections;
import java.util.List;

import static org.schabi.newpipe.player.helper.PlayerHelper.formatPitch;
import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;

Expand Down Expand Up @@ -84,14 +83,13 @@ public abstract class ServicePlayerActivity extends AppCompatActivity

private ImageButton repeatButton;
private ImageButton backwardButton;
private ImageButton fastRewindButton;
private ImageButton playPauseButton;
private ImageButton fastForwardButton;
private ImageButton forwardButton;
private ImageButton shuffleButton;
private ProgressBar progressBar;

private TextView playbackSpeedButton;
private TextView playbackPitchButton;

private Menu menu;

////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -166,6 +164,9 @@ public boolean onOptionsItemSelected(final MenuItem item) {
case R.id.action_append_playlist:
appendAllToPlaylist();
return true;
case R.id.action_playback_speed:
openPlaybackParameterDialog();
return true;
case R.id.action_mute:
player.onMuteUnmuteButtonClicked();
return true;
Expand Down Expand Up @@ -310,20 +311,20 @@ private void buildSeekBar() {
private void buildControls() {
repeatButton = rootView.findViewById(R.id.control_repeat);
backwardButton = rootView.findViewById(R.id.control_backward);
fastRewindButton = rootView.findViewById(R.id.control_fast_rewind);
playPauseButton = rootView.findViewById(R.id.control_play_pause);
fastForwardButton = rootView.findViewById(R.id.control_fast_forward);
forwardButton = rootView.findViewById(R.id.control_forward);
shuffleButton = rootView.findViewById(R.id.control_shuffle);
playbackSpeedButton = rootView.findViewById(R.id.control_playback_speed);
playbackPitchButton = rootView.findViewById(R.id.control_playback_pitch);
progressBar = rootView.findViewById(R.id.control_progress_bar);

repeatButton.setOnClickListener(this);
backwardButton.setOnClickListener(this);
fastRewindButton.setOnClickListener(this);
playPauseButton.setOnClickListener(this);
fastForwardButton.setOnClickListener(this);
forwardButton.setOnClickListener(this);
shuffleButton.setOnClickListener(this);
playbackSpeedButton.setOnClickListener(this);
playbackPitchButton.setOnClickListener(this);
}

private void buildItemPopupMenu(final PlayQueueItem item, final View view) {
Expand Down Expand Up @@ -473,16 +474,16 @@ public void onClick(final View view) {
player.onRepeatClicked();
} else if (view.getId() == backwardButton.getId()) {
player.onPlayPrevious();
} else if (view.getId() == fastRewindButton.getId()) {
player.onFastRewind();
} else if (view.getId() == playPauseButton.getId()) {
player.onPlayPause();
} else if (view.getId() == fastForwardButton.getId()) {
player.onFastForward();
} else if (view.getId() == forwardButton.getId()) {
player.onPlayNext();
} else if (view.getId() == shuffleButton.getId()) {
player.onShuffleClicked();
} else if (view.getId() == playbackSpeedButton.getId()) {
openPlaybackParameterDialog();
} else if (view.getId() == playbackPitchButton.getId()) {
openPlaybackParameterDialog();
} else if (view.getId() == metadata.getId()) {
scrollToSelected();
} else if (view.getId() == progressLiveSync.getId()) {
Expand Down Expand Up @@ -690,8 +691,10 @@ private void onPlayModeChanged(final int repeatMode, final boolean shuffled) {

private void onPlaybackParameterChanged(final PlaybackParameters parameters) {
if (parameters != null) {
playbackSpeedButton.setText(formatSpeed(parameters.speed));
playbackPitchButton.setText(formatPitch(parameters.pitch));
if (menu != null && player != null) {
final MenuItem item = menu.findItem(R.id.action_playback_speed);
item.setTitle(formatSpeed(parameters.speed));
}
}
}

Expand Down
40 changes: 22 additions & 18 deletions app/src/main/res/layout-land/activity_player_queue_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
tools:ignore="RtlHardcoded">

<ImageButton
android:id="@+id/control_backward"
android:id="@+id/control_fast_rewind"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
Expand All @@ -121,7 +121,7 @@
android:focusable="true"
android:scaleType="fitCenter"
android:tint="?attr/colorAccent"
android:src="@drawable/exo_controls_previous"
android:src="@drawable/exo_controls_rewind"
android:background="?attr/selectableItemBackgroundBorderless"
tools:ignore="ContentDescription"/>

Expand Down Expand Up @@ -161,7 +161,7 @@
android:visibility="invisible"/>

<ImageButton
android:id="@+id/control_forward"
android:id="@+id/control_fast_forward"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
Expand All @@ -172,7 +172,7 @@
android:focusable="true"
android:scaleType="fitCenter"
android:tint="?attr/colorAccent"
android:src="@drawable/exo_controls_next"
android:src="@drawable/exo_controls_fastforward"
tools:ignore="ContentDescription"/>
</RelativeLayout>

Expand All @@ -185,8 +185,8 @@
android:orientation="horizontal"
tools:ignore="RtlHardcoded">

<TextView
android:id="@+id/control_playback_speed"
<ImageButton
android:id="@+id/control_backward"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="5dp"
Expand All @@ -195,11 +195,13 @@
android:layout_toLeftOf="@+id/control_repeat"
android:gravity="center"
android:minWidth="50dp"
android:text="1x"
android:textColor="?attr/colorAccent"
android:textStyle="bold"
android:background="?attr/selectableItemBackground"
tools:ignore="HardcodedText,RtlHardcoded"/>
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:scaleType="fitXY"
android:src="@drawable/exo_controls_previous"
android:tint="?attr/colorAccent"
tools:ignore="ContentDescription" />

<ImageButton
android:id="@+id/control_repeat"
Expand Down Expand Up @@ -236,8 +238,8 @@
android:src="@drawable/ic_shuffle_white_24dp"
tools:ignore="ContentDescription"/>

<TextView
android:id="@+id/control_playback_pitch"
<ImageButton
android:id="@+id/control_forward"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="5dp"
Expand All @@ -246,11 +248,13 @@
android:layout_toRightOf="@+id/control_shuffle"
android:gravity="center"
android:minWidth="50dp"
android:text="100%"
android:textColor="?attr/colorAccent"
android:textStyle="bold"
android:background="?attr/selectableItemBackground"
tools:ignore="HardcodedText,RtlHardcoded"/>
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:scaleType="fitXY"
android:src="@drawable/exo_controls_next"
android:tint="?attr/colorAccent"
tools:ignore="ContentDescription" />
</RelativeLayout>
</RelativeLayout>

Expand Down
64 changes: 31 additions & 33 deletions app/src/main/res/layout/activity_player_queue_control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,6 @@
android:orientation="horizontal"
tools:ignore="RtlHardcoded">

<TextView
android:id="@+id/control_playback_speed"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/control_repeat"
android:gravity="center"
android:minWidth="50dp"
android:text="1x"
android:textColor="?attr/colorAccent"
android:textStyle="bold"
android:background="?attr/selectableItemBackground"
tools:ignore="HardcodedText,RtlHardcoded"/>

<ImageButton
android:id="@+id/control_repeat"
android:layout_width="30dp"
Expand All @@ -207,7 +191,7 @@
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="@+id/control_play_pause"
android:layout_toLeftOf="@+id/control_fast_rewind"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
Expand All @@ -216,6 +200,20 @@
android:src="@drawable/exo_controls_previous"
tools:ignore="ContentDescription"/>

<ImageButton
android:id="@+id/control_fast_rewind"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="@id/control_play_pause"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:scaleType="fitCenter"
android:tint="?attr/colorAccent"
android:src="@drawable/exo_controls_rewind"/>

<ImageButton
android:id="@+id/control_play_pause"
android:layout_width="50dp"
Expand Down Expand Up @@ -251,13 +249,28 @@
android:visibility="invisible"
tools:visibility="visible"/>


<ImageButton
android:id="@+id/control_fast_forward"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_toRightOf="@id/control_play_pause"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
android:scaleType="fitCenter"
android:tint="?attr/colorAccent"
android:src="@drawable/exo_controls_fastforward"/>

<ImageButton
android:id="@+id/control_forward"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:layout_toRightOf="@+id/control_play_pause"
android:layout_toRightOf="@+id/control_fast_forward"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"
Expand All @@ -282,21 +295,6 @@
android:src="@drawable/ic_shuffle_white_24dp"
tools:ignore="ContentDescription"/>

<TextView
android:id="@+id/control_playback_pitch"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/control_shuffle"
android:gravity="center"
android:minWidth="50dp"
android:text="100%"
android:textColor="?attr/colorAccent"
android:textStyle="bold"
android:background="?attr/selectableItemBackground"
tools:ignore="HardcodedText,RtlHardcoded"/>
</RelativeLayout>

</RelativeLayout>
8 changes: 8 additions & 0 deletions app/src/main/res/menu/menu_play_queue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
android:visible="true"
app:showAsAction="ifRoom"/>


<item
android:id="@+id/action_playback_speed"
android:title="1x"
android:tooltipText="@string/playback_speed_control"
android:visible="true"
app:showAsAction="ifRoom" />

<item
android:id="@+id/action_mute"
android:icon="?attr/volume_off"
Expand Down