fix(YouTube - Voice Over Translation): Do not show the VOT button if the patch is disabled
Fixes https://github.com/anddea/revanced-patches/pull/1370#issuecomment-3901622830 Also, add a check to only start playing VOT if the video is actually playing.
This commit is contained in:
parent
1253fd2282
commit
48abec6b41
4 changed files with 23 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ package app.morphe.extension.youtube.patches.overlaybutton
|
|||
|
||||
import android.view.View
|
||||
import app.morphe.extension.shared.utils.Logger
|
||||
import app.morphe.extension.youtube.patches.utils.PatchStatus
|
||||
import app.morphe.extension.youtube.patches.voiceovertranslation.VoiceOverTranslationPatch
|
||||
import app.morphe.extension.youtube.settings.Settings
|
||||
import app.morphe.extension.youtube.shared.PlayerControlButton
|
||||
|
|
@ -57,6 +58,7 @@ object VoiceOverTranslationButton {
|
|||
private fun isButtonEnabled(): Boolean {
|
||||
return Settings.VOT_ENABLED.get()
|
||||
&& !isAdProgressTextVisible()
|
||||
&& PatchStatus.VoiceOverTranslation()
|
||||
}
|
||||
|
||||
private fun onClick(view: View) {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ public class PatchStatus {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean VoiceOverTranslation() {
|
||||
// Replace this with true if the 'Voice Over Translation' patch succeeds
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean SpoofAppVersion() {
|
||||
// Replace this with true if the 'Spoof app version' patch succeeds
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -272,8 +272,17 @@ public class VoiceOverTranslationPatch {
|
|||
player.setVolume(vol, vol);
|
||||
long videoTime = VideoInformation.getVideoTime();
|
||||
if (videoTime > 0) player.seekTo((int) videoTime);
|
||||
applyPlaybackSpeedToPlayer(player);
|
||||
player.start();
|
||||
|
||||
// Only start playing if the video is actually playing.
|
||||
// Otherwise, mark it as paused so it starts automatically when the user hits play.
|
||||
if (VideoState.getCurrent() == VideoState.PLAYING) {
|
||||
// applyPlaybackSpeedToPlayer uses setPlaybackParams, which may
|
||||
// auto-start the player on some Android versions.
|
||||
applyPlaybackSpeedToPlayer(player);
|
||||
player.start();
|
||||
} else {
|
||||
isPaused = true;
|
||||
}
|
||||
});
|
||||
mp.setOnErrorListener((p, what, extra) -> true);
|
||||
mediaPlayer.set(mp);
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ import app.morphe.patches.youtube.utils.patch.PatchList.VOICE_OVER_TRANSLATION
|
|||
import app.morphe.patches.youtube.utils.settings.ResourceUtils.addPreference
|
||||
import app.morphe.patches.youtube.utils.settings.settingsPatch
|
||||
import app.morphe.patches.youtube.player.overlaybuttons.overlayButtonsPatch
|
||||
import app.morphe.patches.youtube.utils.extension.Constants.PATCH_STATUS_CLASS_DESCRIPTOR
|
||||
import app.morphe.patches.youtube.video.information.hookVideoInformation
|
||||
import app.morphe.patches.youtube.video.information.onCreateHook
|
||||
import app.morphe.patches.youtube.video.information.videoInformationPatch
|
||||
import app.morphe.patches.youtube.video.information.videoTimeHook
|
||||
import app.morphe.util.updatePatchStatus
|
||||
|
||||
private const val EXTENSION_VOT_PATH =
|
||||
"$EXTENSION_PATH/patches/voiceovertranslation"
|
||||
|
|
@ -43,6 +45,9 @@ val voiceOverTranslationBytecodePatch = bytecodePatch(
|
|||
hookVideoInformation(
|
||||
"$EXTENSION_VOT_CLASS_DESCRIPTOR->newVideoStarted(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JZ)V"
|
||||
)
|
||||
|
||||
// Update the patch status to enabled for the extension
|
||||
updatePatchStatus(PATCH_STATUS_CLASS_DESCRIPTOR, "VoiceOverTranslation")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue