added progressUpdateInterval to Android (#512)

* use progressUpdateInterval in android

* convert progressUpdateInterval to int
This commit is contained in:
melyamri 2017-03-21 21:26:39 +01:00 committed by Matt Apperson
parent 79a9ea540d
commit d48d7efc5d
3 changed files with 15 additions and 3 deletions

View File

@ -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);
}

View File

@ -30,6 +30,7 @@ public class ReactVideoViewManager extends SimpleViewManager<ReactVideoView> {
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<ReactVideoView> {
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));

View File

@ -1,6 +1,6 @@
{
"name": "react-native-video",
"version": "1.0.0",
"version": "1.1.0",
"description": "A <Video /> element for react-native",
"main": "Video.js",
"license": "MIT",