From c45f5f5b38d516ceb0d8e1421cbe3946e475e069 Mon Sep 17 00:00:00 2001 From: RalfNieuwenhuizen Date: Fri, 31 Mar 2017 18:15:39 +0200 Subject: [PATCH] Add progressUpdateInterval to android-exoplayer (#540) --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 8 +++++++- .../brentvatne/exoplayer/ReactExoplayerViewManager.java | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 b67cc598..8b6aea06 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -50,6 +50,7 @@ import com.google.android.exoplayer2.util.Util; import java.net.CookieHandler; import java.net.CookieManager; import java.net.CookiePolicy; +import java.lang.Math; @SuppressLint("ViewConstructor") class ReactExoplayerView extends FrameLayout implements @@ -91,6 +92,7 @@ class ReactExoplayerView extends FrameLayout implements private String extension; private boolean repeat; private boolean disableFocus; + private float mProgressUpdateInterval = 250.0f; // \ End props // React @@ -110,7 +112,7 @@ class ReactExoplayerView extends FrameLayout implements long pos = player.getCurrentPosition(); eventEmitter.progressChanged(pos, player.getBufferedPercentage()); msg = obtainMessage(SHOW_PROGRESS); - sendMessageDelayed(msg, 1000 - (pos % 1000)); + sendMessageDelayed(msg, Math.round(mProgressUpdateInterval)); } break; } @@ -533,6 +535,10 @@ class ReactExoplayerView extends FrameLayout implements } } + public void setProgressUpdateInterval(final float progressUpdateInterval) { + mProgressUpdateInterval = progressUpdateInterval; + } + public void setRawSrc(final Uri uri, final String extension) { if (uri != null) { boolean isOriginalSourceNull = srcUri == null; diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index 4e995904..dda8d000 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -27,6 +27,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager