From 5a43f62253e58bba150db210fecce04bd989311b Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Mon, 28 May 2018 21:22:47 -0700 Subject: [PATCH 1/2] Generate an onEnd event when the end of the video is reached while repeat is on --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index bc2f70de..97f5ed2f 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -471,6 +471,10 @@ class ReactExoplayerView extends FrameLayout implements // which they seeked. updateResumePosition(); } + if (reason == ExoPlayer.DISCONTINUITY_REASON_PERIOD_TRANSITION + && player.getRepeatMode() == Player.REPEAT_MODE_ONE) { + eventEmitter.end(); + } } @Override From 39d8c4384b2529481406b940a9cb8e4721acfc59 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Mon, 28 May 2018 21:26:23 -0700 Subject: [PATCH 2/2] Add a comment about why we send onEnd from onPositionDiscontinuity when repeat is on --- .../main/java/com/brentvatne/exoplayer/ReactExoplayerView.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 97f5ed2f..20e0f9f5 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -471,6 +471,8 @@ class ReactExoplayerView extends FrameLayout implements // which they seeked. updateResumePosition(); } + // When repeat is turned on, reaching the end of the video will not cause a state change + // so we need to explicitly detect it. if (reason == ExoPlayer.DISCONTINUITY_REASON_PERIOD_TRANSITION && player.getRepeatMode() == Player.REPEAT_MODE_ONE) { eventEmitter.end();