fix(fix-playback): seek to maximum end

This commit is contained in:
oSumAtrIX 2022-11-05 06:24:32 +01:00
parent 6aa0ca9556
commit fd69010def
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -1,34 +1,38 @@
package app.revanced.integrations.patches;
import java.util.Timer;
import app.revanced.integrations.settings.SettingsEnum;
import app.revanced.integrations.utils.LogHelper;
public final class FixPlaybackPatch {
private static Thread currentThread = null;
public static void newVideoLoaded(final String _videoId) {
private static String videoId;
public static void newVideoLoaded(final String videoId) {
if (!SettingsEnum.FIX_PLAYBACK.getBoolean()) return;
if (videoId.equals(FixPlaybackPatch.videoId)) return;
else FixPlaybackPatch.videoId = videoId;
if (currentThread != null) {
currentThread.interrupt();
}
currentThread = new Thread(() -> {
try {
while (true) {
var currentVideoLength = PlayerControllerPatch.getCurrentVideoLength();
if (currentVideoLength > 1) {
PlayerControllerPatch.seekTo(currentVideoLength);
PlayerControllerPatch.seekTo(1);
var currentVideoTime = VideoInformation.getVideoTime();
if (currentVideoTime > -1) {
VideoInformation.seekTo(Integer.MAX_VALUE);
VideoInformation.seekTo(currentVideoTime);
return;
}
try {
Thread.sleep(10);
}
} catch (InterruptedException e) {
LogHelper.debug(FixPlaybackPatch.class, "Thread was interrupted");
}
}
});
currentThread.start();