Skip to content

Commit

Permalink
feat(YouTube Music - Player components): Add `Change seekbar position…
Browse files Browse the repository at this point in the history
…` and `Enable thick seekbar` settings (YouTube Music 7.29.51+)
  • Loading branch information
anddea committed Feb 11, 2025
1 parent fe41640 commit f8a3a95
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ public class PlayerPatch {
Settings.ADD_MINIPLAYER_PREVIOUS_BUTTON.get();
private static final boolean CHANGE_PLAYER_BACKGROUND_COLOR =
Settings.CHANGE_PLAYER_BACKGROUND_COLOR.get();
private static final boolean CHANGE_SEEK_BAR_POSITION =
Settings.CHANGE_SEEK_BAR_POSITION.get();
private static final boolean DISABLE_PLAYER_GESTURE =
Settings.DISABLE_PLAYER_GESTURE.get();
private static final boolean ENABLE_SWIPE_TO_DISMISS_MINIPLAYER =
Settings.ENABLE_SWIPE_TO_DISMISS_MINIPLAYER.get();
private static final boolean ENABLE_THICK_SEEKBAR =
Settings.ENABLE_THICK_SEEKBAR.get();
private static final boolean ENABLE_ZEN_MODE =
Settings.ENABLE_ZEN_MODE.get();
private static final boolean ENABLE_ZEN_MODE_PODCAST =
Expand Down Expand Up @@ -108,6 +112,12 @@ public static int[] changePlayerBackgroundColor(int[] colors) {
return colors;
}

public static boolean changeSeekBarPosition(boolean original) {
return SETTINGS_INITIALIZED
? CHANGE_SEEK_BAR_POSITION
: original;
}

public static boolean disableMiniPlayerGesture() {
return Settings.DISABLE_MINIPLAYER_GESTURE.get();
}
Expand Down Expand Up @@ -186,6 +196,12 @@ public static Object enableSwipeToDismissMiniPlayer(Object object) {
return ENABLE_SWIPE_TO_DISMISS_MINIPLAYER ? null : object;
}

public static boolean enableThickSeekBar(boolean original) {
return SETTINGS_INITIALIZED
? ENABLE_THICK_SEEKBAR
: original;
}

public static int enableZenMode(int originalColor) {
if (ENABLE_ZEN_MODE && originalColor == MUSIC_VIDEO_BACKGROUND_COLOR) {
final VideoType videoType = VideoType.getCurrent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ public class Settings extends BaseSettings {
public static final BooleanSetting CHANGE_PLAYER_BACKGROUND_COLOR = new BooleanSetting("revanced_change_player_background_color", FALSE, true);
public static final StringSetting CUSTOM_PLAYER_BACKGROUND_COLOR_PRIMARY = new StringSetting("revanced_custom_player_background_color_primary", "#000000", true);
public static final StringSetting CUSTOM_PLAYER_BACKGROUND_COLOR_SECONDARY = new StringSetting("revanced_custom_player_background_color_secondary", "#000000", true);
public static final BooleanSetting CHANGE_SEEK_BAR_POSITION = new BooleanSetting("revanced_change_seekbar_position", FALSE, true);
public static final BooleanSetting DISABLE_MINIPLAYER_GESTURE = new BooleanSetting("revanced_disable_miniplayer_gesture", FALSE, true);
public static final BooleanSetting DISABLE_PLAYER_GESTURE = new BooleanSetting("revanced_disable_player_gesture", FALSE, true);
public static final BooleanSetting ENABLE_FORCED_MINIPLAYER = new BooleanSetting("revanced_enable_forced_miniplayer", TRUE);
public static final BooleanSetting ENABLE_SWIPE_TO_DISMISS_MINIPLAYER = new BooleanSetting("revanced_enable_swipe_to_dismiss_miniplayer", TRUE, true);
public static final BooleanSetting ENABLE_THICK_SEEKBAR = new BooleanSetting("revanced_enable_thick_seekbar", TRUE, true);
public static final BooleanSetting ENABLE_ZEN_MODE = new BooleanSetting("revanced_enable_zen_mode", FALSE, true);
public static final BooleanSetting ENABLE_ZEN_MODE_PODCAST = new BooleanSetting("revanced_enable_zen_mode_podcast", FALSE, true);
public static final BooleanSetting HIDE_COMMENT_CHANNEL_GUIDELINES = new BooleanSetting("revanced_hide_comment_channel_guidelines", TRUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import app.revanced.patches.music.utils.extension.Constants.PLAYER_CLASS_DESCRIP
import app.revanced.patches.music.utils.playservice.is_7_18_or_greater
import app.revanced.patches.music.utils.resourceid.colorGrey
import app.revanced.patches.music.utils.resourceid.darkBackground
import app.revanced.patches.music.utils.resourceid.inlineTimeBarProgressColor
import app.revanced.patches.music.utils.resourceid.miniPlayerDefaultText
import app.revanced.patches.music.utils.resourceid.miniPlayerMdxPlaying
import app.revanced.patches.music.utils.resourceid.miniPlayerPlayPauseReplayButton
Expand Down Expand Up @@ -359,6 +360,33 @@ internal val switchToggleColorFingerprint = legacyFingerprint(
)
)

internal val thickSeekBarColorFingerprint = legacyFingerprint(
name = "thickSeekBarColorFingerprint",
returnType = "V",
parameters = listOf("L"),
literals = listOf(inlineTimeBarProgressColor),
customFingerprint = { method, _ ->
method.definingClass.endsWith("/MusicPlaybackControls;")
}
)

internal val thickSeekBarFeatureFlagFingerprint = legacyFingerprint(
name = "thickSeekBarFeatureFlagFingerprint",
returnType = "Z",
parameters = emptyList(),
literals = listOf(45659062L),
)

internal val thickSeekBarInflateFingerprint = legacyFingerprint(
name = "thickSeekBarInflateFingerprint",
returnType = "V",
parameters = emptyList(),
customFingerprint = { method, _ ->
method.definingClass.endsWith("/MusicPlaybackControls;") &&
method.name == "onFinishInflate"
}
)

internal val zenModeFingerprint = legacyFingerprint(
name = "zenModeFingerprint",
returnType = "V",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import app.revanced.patches.music.utils.playservice.is_6_27_or_greater
import app.revanced.patches.music.utils.playservice.is_6_42_or_greater
import app.revanced.patches.music.utils.playservice.is_7_18_or_greater
import app.revanced.patches.music.utils.playservice.is_7_25_or_greater
import app.revanced.patches.music.utils.playservice.is_7_29_or_greater
import app.revanced.patches.music.utils.playservice.is_8_03_or_greater
import app.revanced.patches.music.utils.playservice.versionCheckPatch
import app.revanced.patches.music.utils.resourceid.colorGrey
Expand Down Expand Up @@ -55,6 +56,7 @@ import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
import app.revanced.util.fingerprint.injectLiteralInstructionViewCall
import app.revanced.util.fingerprint.matchOrNull
import app.revanced.util.fingerprint.matchOrThrow
import app.revanced.util.fingerprint.methodCall
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.fingerprint.mutableClassOrThrow
import app.revanced.util.fingerprint.resolvable
Expand All @@ -71,6 +73,7 @@ import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
Expand Down Expand Up @@ -488,6 +491,52 @@ val playerComponentsPatch = bytecodePatch(

// endregion

// region patch for enable thick seek bar

var thickSeekBar = false

fun MutableMethod.thickSeekBarHook(index: Int, methodName: String = "enableThickSeekBar") {
val register = getInstruction<OneRegisterInstruction>(index + 1).registerA

addInstructions(
index + 2, """
invoke-static {v$register}, $PLAYER_CLASS_DESCRIPTOR->$methodName(Z)Z
move-result v$register
"""
)
}

if (is_7_25_or_greater) {
val thickSeekBarMethodCall = thickSeekBarFeatureFlagFingerprint.methodCall()
val filter: Instruction.() -> Boolean = {
opcode == Opcode.INVOKE_VIRTUAL &&
getReference<MethodReference>()?.toString() == thickSeekBarMethodCall
}

thickSeekBarInflateFingerprint.methodOrThrow().apply {
val indexes = findInstructionIndicesReversed(filter)

thickSeekBarHook(indexes.first(), "changeSeekBarPosition")
thickSeekBarHook(indexes.last())
}

if (is_7_29_or_greater) {
thickSeekBarColorFingerprint.methodOrThrow().apply {
findInstructionIndicesReversed(filter).forEach { thickSeekBarHook(it) }
}
}

addSwitchPreference(
CategoryType.PLAYER,
"revanced_change_seekbar_position",
"false"
)

thickSeekBar = true
}

// endregion

// region patch for disable gesture in player

val playerViewPagerConstructorMethod =
Expand Down Expand Up @@ -721,6 +770,14 @@ val playerComponentsPatch = bytecodePatch(

// endregion

if (thickSeekBar) {
addSwitchPreference(
CategoryType.PLAYER,
"revanced_enable_thick_seekbar",
"true"
)
}

// region patch for enable zen mode (~ 6.34)

// this method is used for old player background (deprecated since YT Music v6.34.51)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ var historyMenuItem = -1L
private set
var inlineTimeBarAdBreakMarkerColor = -1L
private set
var inlineTimeBarProgressColor = -1L
private set
var interstitialsContainer = -1L
private set
var isTablet = -1L
Expand Down Expand Up @@ -174,6 +176,10 @@ internal val sharedResourceIdPatch = resourcePatch(
COLOR,
"inline_time_bar_ad_break_marker_color"
]
inlineTimeBarProgressColor = resourceMappings[
COLOR,
"inline_time_bar_progress_color"
]
interstitialsContainer = resourceMappings[
ID,
"interstitials_container"
Expand Down

0 comments on commit f8a3a95

Please sign in to comment.