|
1 | 1 | package app.revanced.integrations.patches; |
2 | 2 |
|
3 | | -import java.util.Timer; |
4 | | - |
5 | 3 | import app.revanced.integrations.settings.SettingsEnum; |
6 | 4 | import app.revanced.integrations.utils.LogHelper; |
7 | 5 |
|
8 | 6 | public final class FixPlaybackPatch { |
9 | 7 | 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) { |
11 | 11 | if (!SettingsEnum.FIX_PLAYBACK.getBoolean()) return; |
12 | 12 |
|
| 13 | + if (videoId.equals(FixPlaybackPatch.videoId)) return; |
| 14 | + else FixPlaybackPatch.videoId = videoId; |
| 15 | + |
13 | 16 | if (currentThread != null) { |
14 | 17 | currentThread.interrupt(); |
15 | 18 | } |
16 | 19 |
|
17 | 20 | 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 | + } |
25 | 30 |
|
26 | | - try { |
27 | 31 | Thread.sleep(10); |
28 | | - } catch (InterruptedException e) { |
29 | | - LogHelper.debug(FixPlaybackPatch.class, "Thread was interrupted"); |
30 | 32 | } |
| 33 | + } catch (InterruptedException e) { |
| 34 | + LogHelper.debug(FixPlaybackPatch.class, "Thread was interrupted"); |
31 | 35 | } |
32 | 36 | }); |
33 | 37 |
|
|
0 commit comments