Fix unskip not working on certain segments

Separates hiding buttons and the destruction of unskip tracking variables.

Unskip functionality may break when two segments are very close to each other. See 3:15:00 --> https://www.youtube.com/live/1ThO140eQY4?si=Vpb9A5eE7xeK2cuf&t=11700
This commit is contained in:
Mikooo 2024-04-04 12:57:21 -04:00
parent c995fdb189
commit 054aed2821

View file

@ -2501,7 +2501,13 @@ public final class Player implements PlaybackListener, Listener {
if (lastSegment != null
&& progress > lastSegment.endTime + UNSKIP_WINDOW_MILLIS) {
// un-skip window is over
destroyUnskipVars();
hideUnskipButtons();
lastSegment = null;
autoSkipGracePeriod = false;
if (DEBUG) {
Log.d("SPONSOR_BLOCK", "Destroyed last segment variables (UNSKIP)");
}
} else if (lastSegment != null
&& progress < lastSegment.endTime + UNSKIP_WINDOW_MILLIS
&& progress >= lastSegment.startTime) {
@ -2509,17 +2515,15 @@ public final class Player implements PlaybackListener, Listener {
return lastSegment;
}
destroyUnskipVars();
hideUnskipButtons();
return null;
});
}
private void destroyUnskipVars() {
private void hideUnskipButtons() {
if (DEBUG) {
Log.d("SPONSOR_BLOCK", "Destroying last segment variables, hiding manual skip buttons");
Log.d("SPONSOR_BLOCK", "Hiding manual skip buttons (UNSKIP)");
}
lastSegment = null;
autoSkipGracePeriod = false;
UIs.call(PlayerUi::hideAutoSkip);
UIs.call(PlayerUi::hideAutoUnskip);
}