mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-11-07 20:57:02 +01:00
fix(fix-playback): seek to maximum end
This commit is contained in:
parent
6aa0ca9556
commit
fd69010def
@ -1,33 +1,37 @@
|
||||
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(() -> {
|
||||
while (true) {
|
||||
var currentVideoLength = PlayerControllerPatch.getCurrentVideoLength();
|
||||
if (currentVideoLength > 1) {
|
||||
PlayerControllerPatch.seekTo(currentVideoLength);
|
||||
PlayerControllerPatch.seekTo(1);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
while (true) {
|
||||
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");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
LogHelper.debug(FixPlaybackPatch.class, "Thread was interrupted");
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user