diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoView.java b/android/src/main/java/com/brentvatne/react/ReactVideoView.java index 8b92a5e3..94a25a0e 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoView.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoView.java @@ -26,6 +26,7 @@ import com.yqritc.scalablevideoview.Size; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.lang.Math; @SuppressLint("ViewConstructor") public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnPreparedListener, MediaPlayer @@ -92,6 +93,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP private boolean mPaused = false; private boolean mMuted = false; private float mVolume = 1.0f; + private float mProgressUpdateInterval = 250.0f; private float mRate = 1.0f; private boolean mPlayInBackground = false; private boolean mActiveStatePauseStatus = false; @@ -128,8 +130,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP mEventEmitter.receiveEvent(getId(), Events.EVENT_PROGRESS.toString(), event); // Check for update after an interval - // TODO: The update interval is fixed at 250. There is a property in React component that defines this value. Totally ignored !!! - mProgressUpdateHandler.postDelayed(mProgressUpdateRunnable, 250); + mProgressUpdateHandler.postDelayed(mProgressUpdateRunnable, Math.round(mProgressUpdateInterval)); } } }; @@ -368,6 +369,10 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP setMutedModifier(mMuted); } + public void setProgressUpdateInterval(final float progressUpdateInterval) { + mProgressUpdateInterval = progressUpdateInterval; + } + public void setRateModifier(final float rate) { mRate = rate; @@ -382,6 +387,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP setRepeatModifier(mRepeat); setPausedModifier(mPaused); setMutedModifier(mMuted); + setProgressUpdateInterval(mProgressUpdateInterval); // setRateModifier(mRate); } diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java b/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java index 5dff2f2f..983113d5 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoViewManager.java @@ -30,6 +30,7 @@ public class ReactVideoViewManager extends SimpleViewManager { public static final String PROP_PAUSED = "paused"; public static final String PROP_MUTED = "muted"; public static final String PROP_VOLUME = "volume"; + public static final String PROP_PROGRESS_UPDATE_INTERVAL = "progressUpdateInterval"; public static final String PROP_SEEK = "seek"; public static final String PROP_RATE = "rate"; public static final String PROP_PLAY_IN_BACKGROUND = "playInBackground"; @@ -123,6 +124,11 @@ public class ReactVideoViewManager extends SimpleViewManager { videoView.setVolumeModifier(volume); } + @ReactProp(name = PROP_PROGRESS_UPDATE_INTERVAL, defaultFloat = 250.0f) + public void setProgressUpdateInterval(final ReactVideoView videoView, final float progressUpdateInterval) { + videoView.setProgressUpdateInterval(progressUpdateInterval); + } + @ReactProp(name = PROP_SEEK) public void setSeek(final ReactVideoView videoView, final float seek) { videoView.seekTo(Math.round(seek * 1000.0f)); diff --git a/package.json b/package.json index 6a109375..38d798e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-video", - "version": "1.0.0", + "version": "1.1.0", "description": "A