Skip to content
This repository was archived by the owner on Oct 26, 2024. It is now read-only.

Commit fd69010

Browse files
committed
fix(fix-playback): seek to maximum end
1 parent 6aa0ca9 commit fd69010

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

app/src/main/java/app/revanced/integrations/patches/FixPlaybackPatch.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
package app.revanced.integrations.patches;
22

3-
import java.util.Timer;
4-
53
import app.revanced.integrations.settings.SettingsEnum;
64
import app.revanced.integrations.utils.LogHelper;
75

86
public final class FixPlaybackPatch {
97
private static Thread currentThread = null;
10-
public static void newVideoLoaded(final String _videoId) {
8+
private static String videoId;
9+
10+
public static void newVideoLoaded(final String videoId) {
1111
if (!SettingsEnum.FIX_PLAYBACK.getBoolean()) return;
1212

13+
if (videoId.equals(FixPlaybackPatch.videoId)) return;
14+
else FixPlaybackPatch.videoId = videoId;
15+
1316
if (currentThread != null) {
1417
currentThread.interrupt();
1518
}
1619

1720
currentThread = new Thread(() -> {
18-
while (true) {
19-
var currentVideoLength = PlayerControllerPatch.getCurrentVideoLength();
20-
if (currentVideoLength > 1) {
21-
PlayerControllerPatch.seekTo(currentVideoLength);
22-
PlayerControllerPatch.seekTo(1);
23-
return;
24-
}
21+
try {
22+
while (true) {
23+
var currentVideoTime = VideoInformation.getVideoTime();
24+
25+
if (currentVideoTime > -1) {
26+
VideoInformation.seekTo(Integer.MAX_VALUE);
27+
VideoInformation.seekTo(currentVideoTime);
28+
return;
29+
}
2530

26-
try {
2731
Thread.sleep(10);
28-
} catch (InterruptedException e) {
29-
LogHelper.debug(FixPlaybackPatch.class, "Thread was interrupted");
3032
}
33+
} catch (InterruptedException e) {
34+
LogHelper.debug(FixPlaybackPatch.class, "Thread was interrupted");
3135
}
3236
});
3337

0 commit comments

Comments
 (0)