generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(YouTube Music - Exclusive audio playback): Support latest version
- Loading branch information
Showing
2 changed files
with
20 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 15 additions & 9 deletions
24
src/main/kotlin/app/revanced/patches/music/audio/exclusiveaudio/patch/ExclusiveAudioPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
package app.revanced.patches.music.audio.exclusiveaudio.patch | ||
|
||
import app.revanced.extensions.exception | ||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patches.music.annotations.MusicCompatibility | ||
import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint | ||
import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AllowExclusiveAudioPlaybackFingerprint | ||
|
||
@Patch | ||
@Name("Exclusive audio playback") | ||
@Description("Enables the option to play music without video.") | ||
@Description("Enables the option to play audio without video.") | ||
@MusicCompatibility | ||
class ExclusiveAudioPatch : BytecodePatch( | ||
listOf(AudioOnlyEnablerFingerprint) | ||
listOf(AllowExclusiveAudioPlaybackFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
val method = AudioOnlyEnablerFingerprint.result!!.mutableMethod | ||
method.replaceInstruction(method.implementation!!.instructions.count() - 1, "const/4 v0, 0x1") | ||
method.addInstruction("return v0") | ||
AllowExclusiveAudioPlaybackFingerprint.result?.mutableMethod?.apply { | ||
addInstructions( | ||
0, | ||
""" | ||
const/4 v0, 0x1 | ||
return v0 | ||
""" | ||
) | ||
} ?: throw AllowExclusiveAudioPlaybackFingerprint.exception | ||
} | ||
} | ||
} |