mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-12 04:24:36 +02:00
fix(youtube/default-video-quality): fix default video quality/speed being applied when resuming app
This commit is contained in:
parent
afdbee756a
commit
6cf28cd949
@ -57,7 +57,7 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
playerInitMethod = parentResult.mutableClass.methods.first { MethodUtil.isConstructor(it) }
|
||||
|
||||
// hook the player controller for use through integrations
|
||||
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "playerController_onCreateHook")
|
||||
onCreateHook(INTEGRATIONS_CLASS_DESCRIPTOR, "initialize")
|
||||
|
||||
SeekFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let {
|
||||
val resultMethod = it.method
|
||||
@ -157,6 +157,9 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
internal var reactReference: String? = null
|
||||
|
||||
private var offset = 0
|
||||
private var playerInitInsertIndex = 4
|
||||
private var timeInitInsertIndex = 2
|
||||
private var highPrecisionInsertIndex = 0
|
||||
|
||||
private var insertIndex: Int = 0
|
||||
private var videoIdRegister: Int = 0
|
||||
@ -178,21 +181,24 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
)
|
||||
}
|
||||
|
||||
private fun MutableMethod.insert(insert: InsertIndex, register: String, descriptor: String) =
|
||||
addInstruction(insert.index, "invoke-static { $register }, $descriptor")
|
||||
private fun MutableMethod.insert(insertIndex: Int, register: String, descriptor: String) =
|
||||
addInstruction(insertIndex, "invoke-static { $register }, $descriptor")
|
||||
|
||||
private fun MutableMethod.insertTimeHook(insert: InsertIndex, descriptor: String) =
|
||||
insert(insert, "p1, p2", descriptor)
|
||||
private fun MutableMethod.insertTimeHook(insertIndex: Int, descriptor: String) =
|
||||
insert(insertIndex, "p1, p2", descriptor)
|
||||
|
||||
/**
|
||||
* Hook the player controller.
|
||||
* Hook the player controller. Called when a video is opened or the current video is changed.
|
||||
*
|
||||
* Note: This hook is called very early and is called before the video id, video time, video length,
|
||||
* and many other data fields are set.
|
||||
*
|
||||
* @param targetMethodClass The descriptor for the class to invoke when the player controller is created.
|
||||
* @param targetMethodName The name of the static method to invoke when the player controller is created.
|
||||
*/
|
||||
internal fun onCreateHook(targetMethodClass: String, targetMethodName: String) =
|
||||
playerInitMethod.insert(
|
||||
InsertIndex.CREATE,
|
||||
playerInitInsertIndex++,
|
||||
"v0",
|
||||
"$targetMethodClass->$targetMethodName(Ljava/lang/Object;)V"
|
||||
)
|
||||
@ -206,7 +212,7 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
*/
|
||||
internal fun videoTimeHook(targetMethodClass: String, targetMethodName: String) =
|
||||
timeMethod.insertTimeHook(
|
||||
InsertIndex.TIME,
|
||||
timeInitInsertIndex++,
|
||||
"$targetMethodClass->$targetMethodName(J)V"
|
||||
)
|
||||
|
||||
@ -220,15 +226,9 @@ class MainstreamVideoIdPatch : BytecodePatch(
|
||||
*/
|
||||
internal fun highPrecisionTimeHook(targetMethodClass: String, targetMethodName: String) =
|
||||
highPrecisionTimeMethod.insertTimeHook(
|
||||
InsertIndex.HIGH_PRECISION_TIME,
|
||||
highPrecisionInsertIndex++,
|
||||
"$targetMethodClass->$targetMethodName(J)V"
|
||||
)
|
||||
|
||||
enum class InsertIndex(internal val index: Int) {
|
||||
CREATE(4),
|
||||
TIME(2),
|
||||
HIGH_PRECISION_TIME(0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,14 +12,14 @@ import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
|
||||
import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch
|
||||
import app.revanced.patches.youtube.video.quality.bytecode.fingerprints.*
|
||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction
|
||||
import org.jf.dexlib2.iface.reference.FieldReference
|
||||
|
||||
@Name("default-video-quality-bytecode-patch")
|
||||
@DependsOn([LegacyVideoIdPatch::class])
|
||||
@DependsOn([MainstreamVideoIdPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class VideoQualityBytecodePatch : BytecodePatch(
|
||||
@ -62,7 +62,7 @@ class VideoQualityBytecodePatch : BytecodePatch(
|
||||
)
|
||||
} ?: return VideoQualitySettingsParentFingerprint.toErrorResult()
|
||||
|
||||
LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
|
||||
MainstreamVideoIdPatch.onCreateHook(INTEGRATIONS_VIDEO_QUALITY_CLASS_DESCRIPTOR, "newVideoStarted")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
@ -13,17 +13,16 @@ import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.misc.overridespeed.bytecode.fingerprints.VideoSpeedSettingsFingerprint
|
||||
import app.revanced.patches.youtube.misc.overridespeed.bytecode.patch.OverrideSpeedHookPatch
|
||||
import app.revanced.patches.youtube.misc.resourceid.patch.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.misc.videoid.legacy.patch.LegacyVideoIdPatch
|
||||
import app.revanced.patches.youtube.misc.videoid.mainstream.patch.MainstreamVideoIdPatch
|
||||
import app.revanced.patches.youtube.video.livestream.patch.LiveStreamPatch
|
||||
import app.revanced.patches.youtube.video.speed.bytecode.fingerprints.*
|
||||
import app.revanced.util.integrations.Constants.VIDEO_PATH
|
||||
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
|
||||
@Name("default-video-speed-bytecode-patch")
|
||||
@DependsOn(
|
||||
[
|
||||
LegacyVideoIdPatch::class,
|
||||
LiveStreamPatch::class,
|
||||
MainstreamVideoIdPatch::class,
|
||||
OverrideSpeedHookPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
]
|
||||
@ -55,7 +54,7 @@ class VideoSpeedBytecodePatch : BytecodePatch(
|
||||
"invoke-static {}, $INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->setDefaultSpeed()V"
|
||||
) ?: return VideoSpeedSettingsFingerprint.toErrorResult()
|
||||
|
||||
LegacyVideoIdPatch.injectCall("$INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;)V")
|
||||
MainstreamVideoIdPatch.onCreateHook(INTEGRATIONS_VIDEO_SPEED_CLASS_DESCRIPTOR, "newVideoStarted")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user