Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
feat(YouTube - Playback speed): Add option to show speed dialog butto…
Browse files Browse the repository at this point in the history
…n in video player (#636)

Co-authored-by: oSumAtrIX <[email protected]>
  • Loading branch information
MarcaDian and oSumAtrIX authored Jun 2, 2024
1 parent 571ce75 commit 59220d6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static void onFlyoutMenuCreate(RecyclerView recyclerView) {
});
}

private static void showOldPlaybackSpeedMenu() {
public static void showOldPlaybackSpeedMenu() {
// This method is sometimes used multiple times.
// To prevent this, ignore method reuse within 1 second.
final long now = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public class Settings extends BaseSettings {
public static final BooleanSetting HIDE_PLAYER_BUTTONS = new BooleanSetting("revanced_hide_player_buttons", FALSE);
public static final BooleanSetting COPY_VIDEO_URL = new BooleanSetting("revanced_copy_video_url", FALSE);
public static final BooleanSetting COPY_VIDEO_URL_TIMESTAMP = new BooleanSetting("revanced_copy_video_url_timestamp", TRUE);
public static final BooleanSetting PLAYBACK_SPEED_DIALOG_BUTTON = new BooleanSetting("revanced_playback_speed_dialog_button", FALSE);

// External downloader
public static final BooleanSetting EXTERNAL_DOWNLOADER = new BooleanSetting("revanced_external_downloader", FALSE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package app.revanced.integrations.youtube.videoplayer;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;

import app.revanced.integrations.youtube.patches.playback.speed.CustomPlaybackSpeedPatch;
import app.revanced.integrations.youtube.settings.Settings;
import app.revanced.integrations.shared.Logger;

public class PlaybackSpeedDialogButton extends BottomControlButton {
@Nullable
private static PlaybackSpeedDialogButton instance;

public PlaybackSpeedDialogButton(ViewGroup viewGroup) {
super(
viewGroup,
"revanced_playback_speed_dialog_button",
Settings.PLAYBACK_SPEED_DIALOG_BUTTON,
view -> CustomPlaybackSpeedPatch.showOldPlaybackSpeedMenu(),
null
);
}

/**
* Injection point.
*/
public static void initializeButton(View view) {
try {
instance = new PlaybackSpeedDialogButton((ViewGroup) view);
} catch (Exception ex) {
Logger.printException(() -> "initializeButton failure", ex);
}
}

/**
* Injection point.
*/
public static void changeVisibility(boolean showing) {
if (instance != null) instance.setVisibility(showing);
}
}

0 comments on commit 59220d6

Please sign in to comment.