|
19 | 19 | import java.util.Timer; |
20 | 20 | import java.util.TimerTask; |
21 | 21 |
|
22 | | -import app.revanced.integrations.patches.PlayerControllerPatch; |
| 22 | +import app.revanced.integrations.patches.VideoInformation; |
23 | 23 | import app.revanced.integrations.settings.SettingsEnum; |
24 | 24 | import app.revanced.integrations.sponsorblock.objects.SponsorSegment; |
25 | 25 | import app.revanced.integrations.sponsorblock.requests.SBRequester; |
@@ -102,20 +102,18 @@ public static void executeDownloadSegments(String videoId) { |
102 | 102 | } |
103 | 103 |
|
104 | 104 | sponsorSegmentsOfCurrentVideo = segments; |
105 | | -// new Handler(Looper.getMainLooper()).post(findAndSkipSegmentRunnable); |
| 105 | + // new Handler(Looper.getMainLooper()).post(findAndSkipSegmentRunnable); |
106 | 106 | } |
107 | 107 |
|
108 | | - /** |
109 | | - * Called when it's time to update the UI with new second, about once per second, only when playing, also in background |
110 | | - */ |
111 | | - public static void setCurrentVideoTime(long millis) { |
| 108 | + |
| 109 | + public static void setVideoTime(long millis) { |
112 | 110 | LogHelper.debug(PlayerController.class, "setCurrentVideoTime: current video time: " + millis); |
113 | 111 | if (!SettingsEnum.SB_ENABLED.getBoolean()) return; |
114 | 112 | lastKnownVideoTime = millis; |
115 | 113 | if (millis <= 0) return; |
116 | 114 | //findAndSkipSegment(false); |
117 | 115 |
|
118 | | - if (millis == PlayerControllerPatch.getCurrentVideoLength()) { |
| 116 | + if (millis == VideoInformation.getCurrentVideoLength()) { |
119 | 117 | SponsorBlockUtils.hideShieldButton(); |
120 | 118 | SponsorBlockUtils.hideVoteButton(); |
121 | 119 | return; |
@@ -187,22 +185,19 @@ private static void sendViewRequestAsync(final long millis, final SponsorSegment |
187 | 185 | }).start(); |
188 | 186 | } |
189 | 187 |
|
190 | | - /** |
191 | | - * Called very high frequency (once every about 100ms), also in background. It sometimes triggers when a video is paused (couple times in the row with the same value) |
192 | | - */ |
193 | | - public static void setCurrentVideoTimeHighPrecision(final long millis) { |
194 | | - if ((millis < lastKnownVideoTime && lastKnownVideoTime >= PlayerControllerPatch.getCurrentVideoLength()) || millis == 0) { |
| 188 | + public static void setHighPrecisionVideoTime(final long millis) { |
| 189 | + if ((millis < lastKnownVideoTime && lastKnownVideoTime >= VideoInformation.getCurrentVideoLength()) || millis == 0) { |
195 | 190 | SponsorBlockUtils.showShieldButton(); // skipping from end to the video will show the buttons again |
196 | 191 | SponsorBlockUtils.showVoteButton(); |
197 | 192 | } |
198 | 193 | if (lastKnownVideoTime > 0) { |
199 | 194 | lastKnownVideoTime = millis; |
200 | 195 | } else |
201 | | - setCurrentVideoTime(millis); |
| 196 | + setVideoTime(millis); |
202 | 197 | } |
203 | 198 |
|
204 | 199 | public static long getCurrentVideoLength() { |
205 | | - return PlayerControllerPatch.getCurrentVideoLength(); |
| 200 | + return VideoInformation.getCurrentVideoLength(); |
206 | 201 | } |
207 | 202 |
|
208 | 203 | public static long getLastKnownVideoTime() { |
@@ -296,7 +291,7 @@ public static void drawSponsorTimeBars(final Canvas canvas, final float posY) { |
296 | 291 | final float absoluteLeft = sponsorBarLeft; |
297 | 292 | final float absoluteRight = sponsorBarRight; |
298 | 293 |
|
299 | | - final float tmp1 = 1f / (float) PlayerControllerPatch.getCurrentVideoLength() * (absoluteRight - absoluteLeft); |
| 294 | + final float tmp1 = 1f / (float) VideoInformation.getCurrentVideoLength() * (absoluteRight - absoluteLeft); |
300 | 295 | for (SponsorSegment segment : sponsorSegmentsOfCurrentVideo) { |
301 | 296 | float left = segment.start * tmp1 + absoluteLeft; |
302 | 297 | float right = segment.end * tmp1 + absoluteLeft; |
@@ -330,7 +325,7 @@ public static boolean skipToMillisecond(long millisecond) { |
330 | 325 | try { |
331 | 326 | LogHelper.debug(PlayerController.class, "Skipping to millis=" + finalMillisecond); |
332 | 327 | lastKnownVideoTime = finalMillisecond; |
333 | | - PlayerControllerPatch.seekTo(finalMillisecond); |
| 328 | + VideoInformation.seekTo(finalMillisecond); |
334 | 329 | } catch (Exception e) { |
335 | 330 | LogHelper.printException(PlayerController.class, "Cannot skip to millisecond", e); |
336 | 331 | } |
|
0 commit comments