Only complete seek if seek was in progress

This commit is contained in:
Kat Huang 2024-08-17 18:04:24 -06:00
parent 1235efe975
commit 6042eca33b

View File

@ -229,6 +229,7 @@ public class ReactExoplayerView extends FrameLayout implements
*/ */
private boolean isSeeking = false; private boolean isSeeking = false;
private long seekPosition = -1; private long seekPosition = -1;
private boolean isSeekInProgress = false;
// Props from React // Props from React
private Source source = new Source(); private Source source = new Source();
@ -310,6 +311,7 @@ public class ReactExoplayerView extends FrameLayout implements
eventEmitter.onVideoSeekComplete.invoke(player.getCurrentPosition()); eventEmitter.onVideoSeekComplete.invoke(player.getCurrentPosition());
isSeeking = false; isSeeking = false;
seekPosition = -1; seekPosition = -1;
isSeekInProgress = false;
} }
} }
@ -1382,7 +1384,9 @@ public class ReactExoplayerView extends FrameLayout implements
playerControlView.show(); playerControlView.show();
} }
setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback); setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback);
handleSeekCompletion(); if (isSeekInProgress) {
handleSeekCompletion();
}
break; break;
case Player.STATE_ENDED: case Player.STATE_ENDED:
text += "ended"; text += "ended";
@ -2149,6 +2153,7 @@ public class ReactExoplayerView extends FrameLayout implements
public void seekTo(long positionMs) { public void seekTo(long positionMs) {
if (player != null) { if (player != null) {
isSeekInProgress = true;
isSeeking = true; isSeeking = true;
seekPosition = positionMs; seekPosition = positionMs;
player.seekTo(positionMs); player.seekTo(positionMs);